Add Attachment with UpdateListItems?

别来无恙 提交于 2019-12-06 04:25:49

问题


Is it possible to add an attachment to a new list item with UpdateListItems?

I've tried this SOAP, but no dice....

Can someone share with me the proper SOAP structure to get this done?

<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:UpdateListItems>
         <ns1:listName>Some Calendar</ns1:listName>
         <ns1:updates>
            <Batch OnError="Continue" ListVersion="1">
               <Method ID="1" Cmd="New">
                  <Field Name="ID">New</Field>
                  <Field Name="Title">Some Title</Field>
                  <Field Name="EventDate">2010-11-01 07:30:00</Field>
                  <Field Name="Attachments">
                     <Value Type="Attachments">/tmp/details.xml</Value>
                  </Field>
               </Method>
            </Batch>
         </ns1:updates>
      </ns1:UpdateListItems>
   </ns0:Body>
</SOAP-ENV:Envelope>

Thanks!


回答1:


Found the answer to my question. Apparently, using getlistitems to attach a file to an item is not possible. You have to get the _ows_ID value when creating the item, then use the AddAttachment method on the ID value of your item.



来源:https://stackoverflow.com/questions/4100157/add-attachment-with-updatelistitems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!