I am using Listdata.svc to add or update list items on a remote sharepoint server. I need to know that if suppose I am using a tasks list and the items in the tasks list have attachment of file in them, then how to copy those attachments to the remote sharepoint server through "listdata.svc" service.


  • is it possible to use the client object model for this ? Feb 17 '12 at 15:37
  • I am asking ? as well... need answer to this
    – RHM
    Feb 17 '12 at 15:40

i haven't tried getting the binaries using the svc, but if you can get the URL of the attachment then, you can use the client object model to get the actual document.


File.OpenBinaryDirect(context,'server relitive url')

a demo getting the clientcontext object

public ClientContext getClientContext(string url, NetworkCredential credentials)
    ClientContext clientContext = new ClientContext(url);
    clientContext.Credentials = credentials;
    return clientContext;


To upload an atachment using Lists.asmx webservice You must first encapsulate the webservice this can be done using visual studio by adding a service refrence the url to the web service is

the webservice url is http://sharepoint/_vti_bin/Lists.asmx

once the webservice is ecapsulated you can call the addAtatchment method like this:

ListServiceExample.ServiceReference1.ListsSoapClient listWS = new ListServiceExample.ServiceReference1.ListsSoapClient();
NetworkCredential creds = new NetworkCredential("username","password");
creds.Domain = "domain";
listWS.ClientCredentials.Windows.ClientCredential = creds;
listWS.AddAttachment(ListName,ListItemID,fileName,Binary Array);

if you want to see what other methods you can call with this webservice just enter http://sharepoint/_vti_bin/Lists.asmx into your url remember to replace sharepoint with your instances host name.

also the rest of sharepoints webservices can be found in the %14hive%\ISAPI folder

Kind Regards

  • This is to get the attachment from a task item , but how to create an attachment to a taskitem .
    – RHM
    Feb 20 '12 at 8:00
  • to add an attachment you will have to use the List asmx service, i will create a small code snippet for you tonight and add it to the above post Feb 20 '12 at 9:09
  • sorry for the delay here is the answer to your question Feb 21 '12 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.