Copying list attachments using sharepoint webservice namely lists

hi
please anyone tell me how to get sharepoint lists attachment and adding that attachment into another list using sharepoint webservice methods get attachment collection,add attachment
Thanks

To add a new list item attachement
please refer this code
string srcUrl = textBox1.Text;
if (! File.Exists(srcUrl))
throw new ArgumentException(String.Format("{0} does not exist",
srcUrl), "srcUrl");
FileStream fStream = File.OpenRead(srcUrl);
string fileName = fStream.Name.Substring(3);
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
Web_Reference_Folder.Lists listService =
new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;
try
string addAttach = listService.AddAttachment("List_Name", "3",
fileName, contents);
MessageBox.Show(addAttach);
catch (System.Web.Services.Protocols.SoapException ex)
MessageBox.Show("Message:\n" + ex.Message + "\nDetail:\n" +
ex.Detail.InnerText + "\nStackTrace:\n" + ex.StackTrace);
Please remember to click 'Mark as Answer' on the answer if it helps you

Similar Messages

  • Using SharePoint WebServices in APEX

    Hi,
    I'm trying to use sharepoint webservice in apex.
    But sharepoint webservices uses NTLM authentication, and there is no such option in apex web service config.
    I tried to put authentication data in soap header, but I didn't get any answer from the web service.
    When I use default settings I got 401 unathorized response from the sharepoint server.
    Is there some way for use ntlm auth in apex webservices connection ?
    Regards,
    Marcin

    Joel
    thank you for clarification. Really appreciate your help. I was able to get the list. Here is the procedure. The line that fails is highlighed. Basically it can't initialize the session on AD server...
    declare
         p_username          varchar2(25):='test';
         p_password          varchar2(25):='test';
         l_user               varchar2(256);
         l_ldap_server     varchar2(256)     := 'AD host';
         l_domain          varchar2(256)     := 'domain';
         l_ldap_port          number               := 389;
         l_retval          pls_integer;
         l_session          dbms_ldap.session;
         l_cnt               number;
    begin
    --     l_retval := dbms_ldap.unbind_s( l_session );
         l_user               := p_username||'@'||l_domain;
    *     l_session          := dbms_ldap.init( l_ldap_server, l_ldap_port ); -- start session*     
    l_retval          := dbms_ldap.simple_bind_s( l_session, l_user, p_password ); -- auth as user
         l_retval          := dbms_ldap.unbind_s( l_session ); -- unbind
         dbms_output.put_line( 'yes');
    exception when others then
    dbms_output.put_line( 'no');
    raise_application_error(-20101, 'invalid user');
         end;
    thanks, Ed

  • Need to get the name and the Site ID of a specific user using SharePoint Webservices

    Hi,
    I need to get the User's name by passing the Login Name using SharePoint OOB Web Services.
    I need to pass DOMAIN\\Login ID and get the User's Info i.e. Name and the ID of a particular site.
    I'm trying to use GetuserInfo:
    $(document).ready(function () {
    var soapEnv = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
    "<soap:Body>"+
    "<GetUserInfo xmlns=\"http://schemas.microsoft.com/sharepoint/soap/directory/\">"+
    "<userLoginName>DOMAIN\\Login ID</userLoginName>"+
    "</GetUserInfo>"+
    "</soap:Body>"+
    "</soap:Envelope>";
    $.ajax({
    url: "<http://SiteURL>/_vti_bin/usergroup.asmx",
    beforeSend: function (xhr) {
    xhr.setRequestHeader("SOAPAction",
    "http://schemas.microsoft.com/sharepoint/soap/directory/GetUserInfo");
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    complete: processResult,
    contentType: "text/xml; charset=\"utf-8\""
    function processResult(xData, status) {
    alert("Status : " + status);
    alert(xData.responseText);
    console.log(xData.responseText);
    But i get error stating that User does not exist.
    Appreciate all your help.
    Regards,
    Sachin

    Hi Sachin,
    The following code for your reference:
    <script src="http://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    var url ="http://sharepoint/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='contoso\\administrator'";
    $.ajax({
    url: url,
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
    var results=data.d.UserProfileProperties.results;
    error: function (data) {
    </script>
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Create List Item using SharePoint 2010 Workflow

    Hello everyone.
    I found in youtube video using SP Employee Onboarding Web Part, idea is quite simple and powerful. But this web part available only in SP 2013, and I use 2010. So I wanted to develop my own version.
    Questions is:
    I have 2 lists Employee OnBoards (list contains data about new employee) and Employee OnBoards Tasks (list contains approval task). Where field Employee Name from Employee OnBoards list is lookup field in Employee OnBoards Tasks list.
    I need emplement next:
    When new Item created in Employee OnBoards list, it should copy Employee Name value to the Name field of the Employee OnBoards Tasks list.
    I hope I explained understandable.
    Thanks.

    Hi Azamat,
    This you can do by using SharePoint Designer workflow.
    Create a sharepoint designer workflow and invoke that when new item will create in the list Employee
    OnBoards.
    then use Copy List item action to copy employee name to employee on board task list.
    Below link will help you how to use copy list item action in a workflow.
    http://blogs.salmanghani.info/copy-item-workflow-using-sharepoint-designer-2010/
    Hope this will help you.
    Regards
    Soni K

  • How to execute XML batch commands using SharePoint Web services or Client Object Model

    Hi,
    I have a requirement to execute some batch commands to update SharePoint View Style, how can i do it using SharePoint webservices or SharePoint Client Object model.
          I need to execute the following Batch command over a particular web.
    <Method ID="UpdateView">
      <SetVar Name="Cmd">UpdateView</SetVar>
      <SetList Scope="Request">{GUID of List}</SetList>
      <SetVar Name="View">{GUID of View}</SetVar>  
      <SetVar Name="ViewStyle">6</SetVar>
      <SetVar Name="RowLimit">100</SetVar>
      <SetVar Name="Paged">TRUE</SetVar>
    </Method>

    Hi
    I tried it already... But UpdateView Method in the Views.asmx and Lists.asmx, both are not supporting for updating the style of the view (like Boxed, Newsletter...).
    If you have any code sample which will do this job with any of the SharePoint web services, please share it..

  • Copy List Item Attachment for archiving using SharePoint Designer 2013

    hi,
    how to Copy List Item Attachment for archiving using SharePoint Designer 2013

    1. You can use access:
    http://viziblr.com/news/2011/11/5/batch-exporting-sharepoint-2010-list-item-attachments-using.html
    Or you can try below script
    You can loop through each list item, and get each attachment.
    List<SPAttachment> attachments = new List<SPAttachment>();
    SPList list = SPContext.Current.Web.Lists["My List"];
    foreach (SPListItem item in list.Items)
    attachments.AddRange(item.Attachments.Cast<SPAttachment>());
    If this helped you resolve your issue, please mark it Answered

  • Copy ID from one library to list using sharepoint designer workflow 2013

    Hello,
    I am new In SharePoint Designer workflow.
    I want to copy ID [by default] from one SharePoint Library to SharePoint List by using SharePoint Designer workflow 2013.
    So Please provide me any solution on it.
    Thanks,
    Samadhan.

    Hi Bjorn,
    Please create a workflow based on SharePoint 2010 platform, there is OOB action "Copy List Item" which can copy attachment to another list.
    Then use "Update List Item" action to update fields value for the new item. In this action, we could use Item title to locate the newly created item. For your reference:
    However, we cannot make this workflow to start automatically. As workaround, we could use SharePoint Designer to create a Custom Action in the Source List and initiate the workflow. In my test, I created a Custom Action in the type of List Item Menu. Then
    the custom action would appear in the Item ellipsis dropdown menu:
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Use" Copy List Item Extended Activity" to move items in sharepoint list

    Hi
    I use “Copy List Item Extended Activity” in my workflow to move items to special folder in document library.it’s ok. But when I use this action to move items in special folder in list, it dose not work! Why?
    This action only work with document library to move or copy items?
    If not, how I can address special folder of list in “this url” in Copy List Item Extended Activity action?
    Thanx.

    Hi luckstar,
    please have a check on this article:
    http://spdactivities.codeplex.com/wikipage?title=Copy%20List%20Item%20Extended%20Activity&referringTitle=Home
    when copying/moving files in and out of doc. libs, path to a sub folder can be specified as the destination (ex. http://moss/site/doclib/subfolder)
    if should you already done this step, then please have a check the permission from the user account that you use, do the user account
    have the enough permission on that other URL.
    Regards,
    Aries
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • How to Copy list item attachment to document library in SharePoint 2010

    Hi,
    How to Create a folder ("List Item - Title Name") in Document library and copy list items Attachments to the same folder in SharePoint 2010,thanks in advance.
    Regards,
    Selvan.J
    Selvan J

    Hi,
    You should first check whether the folder exists in the library, if the folder not exists, then create it.
    I had modified the code, you can use the following code snippet to achieve it.
    private void EventCopyFileWhenItemCreatedOrUpdated(SPItemEventProperties properties)
    SPSite site = new SPSite(http://YourSiteName);
    SPWeb web = site.OpenWeb();
    SPList doclibList=properties.Web.Lists["YourLibName"];
    bool foundFolder = false;
    if (doclibList.Folders.Count>0)
    foreach (SPListItem fitem in doclibList.Folders)
    if (fitem.Title.Equals("FolderA"))
    foundFolder = true;
    break;
    if (foundFolder == false)
    SPListItem folder = doclibList.Folders.Add(doclibList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder,"FolderA");
    folder.Update();
    string fUrl = doclibList.RootFolder.ServerRelativeUrl+"/FolderA";
    SPFolder myLibrary = web.GetFolder(fUrl);
    if (properties.ListTitle == "YourListName")
    SPListItem sourceItem = properties.ListItem;
    properties.Web.AllowUnsafeUpdates = true;
    //get the folder with the attachments for the source item
    SPFolder sourceItemAttachmentsFolder =
    sourceItem.Web.Folders["Lists"].SubFolders[sourceItem.ParentList.Title].SubFolders["Attachments"].SubFolders[sourceItem.ID.ToString()];
    //Loop over the attachments, and add them to the target item
    foreach (SPFile file in sourceItemAttachmentsFolder.Files)
    if (CheckFileNameExist(file.Name , properties) == false)
    byte[] binFile = file.OpenBinary();
    myLibrary.Files.Add(System.IO.Path.GetFileName(file.Url) , binFile);
    private bool CheckFileNameExist(string fileNameInFileAttach, SPItemEventProperties properties)
    bool flag = false;
    SPList myDocumentLib = properties.Web.Lists["YourLibName"];
    SPQuery spQuery = new SPQuery();
    SPListItemCollection items = myDocumentLib.GetItems(spQuery);
    foreach (SPListItem item in items)
    if (fileNameInFileAttach == item["Name"].ToString())
    flag = true;
    break;
    return flag;
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • [Forum FAQ] Show Attachments in SharePoint 2013 Custom List View

    Introduction:
    By default, there is an Attachments column in the SharePoint List, some people want to display attachments name and click name can open the documents in List View. In this article, we would show you the method with
    REST API, JSLink and jQuery.
    Solution:
    The steps in detail as follows:
    Download the jQuery API  and upload the js file into the
    SiteAssets Document Library.
    Save the following code as a js file (showAttachments.js) and upload it into the
    SiteAssets Document Library.
    (function () {
    // Create object that have the context information about the field that we want to change it output render
    var attachmentsFiledContext = {};
    attachmentsFiledContext.Templates = {};
    attachmentsFiledContext.Templates.Fields = {
    "Attachments": { "View": AttachmentsFiledTemplate }
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(attachmentsFiledContext);
    // This function provides the rendering logic for list view
    function AttachmentsFiledTemplate(ctx) {
    var itemId = ctx.CurrentItem.ID;
    var listName = ctx.ListTitle;
    return getAttachments(listName, itemId);
    //get attachments field properties
    function getAttachments(listName,itemId) {
    var url = _spPageContextInfo.webAbsoluteUrl;
    var requestUri = url + "/_api/web/lists/getbytitle('" + listName + "')/items(" + itemId + ")/AttachmentFiles";
    var str = "";
    // execute AJAX request
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    async: false,
    success: function (data) {
    for (var i = 0; i < data.d.results.length; i++) {
    str += "<a href='" + data.d.results[i].ServerRelativeUrl + "'>" + data.d.results[i].FileName + "</a>";
    if (i != data.d.results.length - 1) {
    str += "<br/>";
    error: function (err) {
    //alert(err);
    return str;
    3.     Edit the list view page.
    4.
    Edit the list web part. Go to Miscellaneous -> JS Link.
    5.    Add the following URL into the JS Link textbox.
    ~site/SiteAssets/jquery-1.11.1.min.js|~site/SiteAssets/showAttachments.js
    Result:<o:p></o:p>
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Hi,
    Thanks for your details steps, with your steps I can reproduce the issue using SharePoint server 2013 without any CU or PU.
    The items not displayed when group by the calculated column.
    However, I had done more research and test, I had found that it’s a known issue.
    I had tested with the SharePoint server 2013 which applied the December CU, the issue disappeared, the items displayed well.
    You can install the December CU for SharePoint server 2013, then test whether it works.
    http://blogs.technet.com/b/stefan_gossner/archive/2013/12/20/december-2013-cu-for-sharepoint-2013-has-been-released.aspx
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • How to send current list item URL in email by using sharepoint 2010 workflow?

    Hi All,
    I had created sharepoint workflow usind SPD 2010. when new item is created it sends the email with link. But it sends current list link not the current item link.
    I tried to use Encoded Absolute URL but this like
    http://asdf.com/Lists/abc/10.00
    but i need something like this
    http://asdf.com/Lists/abc/DispForm.aspx?ID
    I have grow thorough some post and i found that,
    Statically i can write http://asdf.com/Lists/abc/DispForm.aspx?ID= and from Add lookup i can get ID by choosing current item.
    The link which i get is partially hyperlink like this
    http:aasdf.com/Lists/abc/DispForm.aspx?ID=10 (here 10 is not hyperlink)
    when i copy and paste this link it works fine but by clicking it i am not getting true result.
    Please help me to solve this issue.
    Thanks.

    Hi Raymond,
    It works for me. Thank you so much.
    I also have another issue related workflow. If you can help me, i really appreciate you.
    I already configured AAM. I have two Share Point Address which are:
    Default : http://default.com
    Internal : http://intranet.com
    I have List workflow using SharePoint Designer 2010. When new item get create, it sends email to person for approval. But when it sends email it sends Dafault zone URL.
    Dafault zone URL is only accessible through Virtual Machine. We cant access from local machine. So i need to send intranet zone URL in email so user can open through local machine.
    I tried it but i can only able to do for one list. I have to so this general for every list.
    How can i send intranet zone URL?
    Swapping the zone URL is not solution for this issue because after swapping situation is same.
    Thank You.

  • How to copy List item from one list to another using SPD workflow using HTTP call web service

    Hi,
    How to copy List item from one list to another using SPD workflow using HTTP call web service.
    Both the Lists are in different Web applications.
    Regards, Shreyas R S

    Hi Shreyas,
    From your post, it seems that you are using SharePoint 2013 workflow platform in SPD.
    If that is the case, we can use Call HTTP web service action to get the item data, but we cannot use Call HTTP web service to create a new item in the list in another web application with these data.
    As my test, we would get Unauthorized error when using Call HTTP web service action to create a new item in a list in another web application.
    So I recommend to achieve this goal programmatically.
    More references:
    https://msdn.microsoft.com/en-us/library/office/jj164022.aspx
    https://msdn.microsoft.com/en-us/library/office/dn292552.aspx?f=255&MSPPError=-2147217396
    Thanks,
    Victoria
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How create animated power view reports using sharepoint list as a data source in sharepoint 2010?

    Hi All,
    I got a client requirement to create reports using SharePoint List as data source. The report should show reflection depends on values changed (I mean animation).
    I have heard about the power view/power pivot which does this kind of animations in reports.
    Can someone please guide me on creating reports which shows animations
    In power view/power pivot using SharePoint List as data source in SharePoint 2010.
    Thanks in advance.
    MercuryMan

    Hi MercuryMan,
    Yes, Power View, a feature of SQL Server 2012 Reporting Services Add-in for Microsoft SharePoint Server 2010 or SharePoint 2013 Enterprise Edition, is an interactive data exploration, visualization, and presentation experience.
    It provides multiple views featuring tiles, slicers, a chart filter, and a number of visualizations, including cards, small multiples, and a bubble chart. So, we can use Power View to do intuitive ad-hoc reporting for business users such as data analysts, business
    decision makers, and information workers.
    Currently, Power View report only supports two types of data models: PowerPivot Worksheet, and data models based on Analysis Services Tabular Model or Multidimensional Cube.
    In your scenario, you can create PowerPivot worksheets using SharePoint List as data source, deploy the PowerPivot worksheet to a SharePoint Library or PowerPivot Gallery, and then generate Power View reports based on the PowerPivot worksheets on the SharePoint
    site.
    To use SharePoint List as data source in Excel PowerPivot, you can refer to the following resource:
    http://blogs.technet.com/b/excel_services__powerpivot_for_sharepoint_support_blog/archive/2013/07/11/excel-services-using-a-sharepoint-list-as-a-data-source.aspx 
    http://technet.microsoft.com/en-us/library/hh230322.aspx 
    To create a Power View report based on PowerPivot model, you can refer to the following links:
    http://technet.microsoft.com/en-us/library/hh231522.aspx 
    http://technet.microsoft.com/en-us/library/hh759325.aspx 
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • Send a list item as a bulk e-mail using SharePoint 2010

    My scenario is to e-mail newsletters to a group of users (running into 1000's) and we were thinking about any pro's and cons of using SharePoint here.
    Preferable if the newsletter were embedded in the e-mail so there is no need to give permission to a user to visit the site (or do we have to anyway?)
    Also, a functionality such that, every list item could have an option such as "E-mail to Group 1" or "Email to Group 2" that would allow the item to be mass e-mailed.
    Group 1 assume to be a group of 500 individuals with only e-mail addresses known...
    If SharePoint seems right, then can anyone suggest me how to go about this? If it is possible with OOTB/designer?

    For you scenario, you could explore ECB Menu action using SharePoint designer.
    The logic would be first fire up SharePoint designer and create an ECB menu to start a workflow ie initiate workflow in SharePoint designer (you need to create two workflows each for Group1 and Group2 to make it simple)
    Next step would be to create a workflow to send an email to the selected group and use item values within the workflow to create the newletter.
    here are some reference on how to -
    http://sharepointyankee.com/2009/12/19/adding-custom-actions-to-the-list-item-menu-in-sharepoint-2010-using-sharepoint-designer-2010/
    http://blog-sharepoint.blogspot.com/2011/10/tutorial-add-custom-list-actions-using.html
    http://office.microsoft.com/en-us/sharepoint-designer-help/send-e-mail-in-a-workflow-HA010239042.aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • How to create purchase order using SharePoint Custom List

    Hi All,
    Can you please provide some example or link to create Purchase Order using SharePoint List / SharePoint Designer.
    Thanks

    Hi,
    It would be difficult to achieve what you want with the OOTB features of only one list.
    Per my understanding, there would be two main functionalities in the solution you want:
    1. Calculate and display the “Balance Qty” dynamically based on the values of “Order Qty” and “Deliver Qty”;
    2. Trace the “Deliver Date” and “Deliver Qty” as per “Purchase No”;
    As a workaround, I would suggest you create two lists as below:
    1. List “Orders”: Saving the upcoming orders per “Purchase No”, one “Order Qty” related to one unique “Purchase No”.
    Columns in this list:
    Purchase No(Number);
    Order Date(Date);
    Order Qty(Number);
    2. List “Deliveries”: Recording each delivery, one “Deliver Qty” to one unique existing “Purchase No” in list “Orders”.
    Columns in this list:
    Purchase No(Lookup “Purchase No” in list “Orders”);
    Order Date(Additional Lookup column along with “Purchase No”);
    Order Qty(Additional Lookup column along with “Purchase No”);
    Deliver Date(Date);
    Deliver Qty(Number);
    Balance Qty(Number);
    More information about
    Lookup column in SharePoint List:
    http://msdn.microsoft.com/en-us/library/office/ff728095(v=office.14).aspx
    http://zimmergren.net/technical/sp-2010-how-to-relational-lists-in-sharepoint-2010
    In the “Deliveries” list, we can trace each “Deliver Qty” and “Deliver Date” easily by filtering the “Purchase No” column in the list view page.
    For the dynamic values in “Balance Qty” column, Event Receiver with custom code would be needed as we will need to query the “Order Qty” in “Orders” list and all the
    existing “Deliver Qty” value per “Purchase No” in “Deliveries” list.
    An idea about
    how to implement a Purchase Order system in this blog would be helpful:
    http://ethan-deng.blogspot.jp/2013/03/purchase-order-management-system.html
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

Maybe you are looking for

  • Java.io.File.getCanonicalFile() IOExceptions

    The javadoc for the java.io.File.getCanonicalFile() method says that it can fail with an IOException, saying: @ throws IOException If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem que

  • How to maintain space between table and header in ssrs

    Hi Everyone,    I have created a report. In page header of this report, On First Page space between header and body is good , but from next page, space is not maintain.  Please suggest me how to maintain space at every page of report. Thanks. 

  • Maxed Out Processor - Viewing Here, fans on.

    Apple definitely changed this forum to something my MBP doesn't like any more. This is a MacBookPro 09 - 13"  -  10.06 08  -  Proc - 2.53 / Core 2 Duo I just posted a fix for a problem I was having - and my Processor went off the chart and fans came

  • Iphoto crashes during import from drive.

    I have a new macbook air with iphoto 9.1.5.  I've imported pictures directly from an sd card out of my camera and it works fine.  I transferred all my old pictures onto the computer, but every time I try to import them into iphoto, it unexpectedly qu

  • Problem with load XML data

    Hi. I have a problem this load XML data. For example: file name: 01-05-2008.xml => in this file all data have date=01.05.2008. Once i load period 01.05.2008 to 10.05.2008 my app load 10 files. Sometimes some row this greater date stay earlier then ro