c# - DeleteAttachment method in List web service for sharepoint 2010 is with "Microsoft.SharePoint.SoapServer.SoapServerException" error -


i have document library named "registrant" , inside library registrants uploading documents own folder "registrant1_guidofregistrant1"

currently situation "http://registry.example.com/crmdocuments/contact/"

where "crmdocuments" folder inside. have multiple document libraries registrant(contact name appears in url because "registrant" display name).

i have web portal in registrant can register , login through:

"http://registry.example.com/register.aspx"

after registration, can upload documents share point , listed in web portal , there provision delete documents if want.

at initial upload system creating folder inside "registrant" document library in format "registrant1_guidofregistrant1" , files stored inside folder.

i using share point 2010 web services create folder , upload documents, list of items specific folder , delete attachment inside folder.

web service references in msdn are:

msdn.microsoft.com/en-us/library/office/websvclists.lists.deleteattachment%28v=office.14%29.aspx

i creating "service reference" these web services create folder, upload documents , list of items specific folder working perfectly, delete not.

i have code reference:

    basichttpbinding bind = new basichttpbinding(basichttpsecuritymode.transportcredentialonly);             basichttpsecurity security = new basichttpsecurity();             httptransportsecurity http = new httptransportsecurity();             http.clientcredentialtype = httpclientcredentialtype.ntlm;              security.transport = http;             security.mode = basichttpsecuritymode.transportcredentialonly;             bind.security = security;              sharepoint.list.listssoapclient client = new sharepoint.list.listssoapclient(bind, new endpointaddress("http://registry.example.com/crmdocuments/_vti_bin/lists.asmx"));               networkcredential cred = new networkcredential("userid", "password", "domain");              client.clientcredentials.windows.allowedimpersonationlevel = system.security.principal.tokenimpersonationlevel.impersonation;             client.clientcredentials.windows.clientcredential = cred;   client.deleteattachment("registrant", "516", "http://registry.example.com/crmdocuments/contact/registrant1_b2ad3754-65a8-e311-befb-60a44cce3a94/sample1_education.jpg"); 

this coming error:

"exception of type 'microsoft.sharepoint.soapserver.soapserverexception' thrown" 

with stack trace:

server stack trace:    @ system.servicemodel.channels.servicechannel.handlereply(proxyoperationruntime operation, proxyrpc& rpc)    @ system.servicemodel.channels.servicechannel.call(string action, boolean oneway, proxyoperationruntime operation, object[] ins, object[] outs, timespan timeout)    @ system.servicemodel.channels.servicechannelproxy.invokeservice(imethodcallmessage methodcall, proxyoperationruntime operation)    @ system.servicemodel.channels.servicechannelproxy.invoke(imessage message)  exception rethrown @ [0]:    @ system.runtime.remoting.proxies.realproxy.handlereturnmessage(imessage reqmsg, imessage retmsg)    @ system.runtime.remoting.proxies.realproxy.privateinvoke(messagedata& msgdata, int32 type)    @ registry.sharepoint.list.listssoap.deleteattachment(deleteattachmentrequest request)    @ registry.sharepoint.list.listssoapclient.registry.sharepoint.list.listssoap.deleteattachment(deleteattachmentrequest request) in c:\dev\solution\lib\service references\sharepoint.list\reference.cs:line 2923    @ registry.sharepoint.list.listssoapclient.deleteattachment(string listname, string listitemid, string url) in c:\dev\psw_solution\pswlib\service references\sharepoint.list\reference.cs:line 2932    @ registry.pswdocumentlocation.deleteitemindocumentlibrary(xrmservicecontext x, entity entity, string smossurl, networkcredential cred, string id, string url) in c:\dev\solution\lib\documentlocation.cs:line 203 

can have thoughts on problem?

thanks in advance.

it seems trying delete file folder, not attachment, since attachment has following url format:

http://<server>/<site>/lists/<listname>/attachments/<listitemid>/<attachmentfileurl>  

the following code used verify whether specified item contains attachments , if exist delete first attachment :

  var attachmentsresult = client.getattachmentcollection(listtitle, listitemid);   var hasattachments = attachmentsresult.haselements;   if (hasattachments)   {        var attachmentfileurl = attachmentsresult.elements().firstordefault().value;       client.deleteattachment(listtitle, listitemid, attachmentfileurl);   } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -