How do I rename a file using the SharePoint web services?

谁说胖子不能爱 提交于 2019-12-06 04:04:38

问题


I have a custom definition for a document library and I am trying to rename documents within the library using only the out of the box web services. Having defined a view with the "Name" field supplied and trying the "LinkFilename", my calls to rename a file are respectively returning a failure or ignoring the new value.

How do I rename a file using the SharePoint web services?


回答1:


Use the Lists.UpdateListItems web method. The XML request should look like:

<Batch OnError="Continue" PreCalc="TRUE" ListVersion="0">
   <Method ID="1" Cmd="Update">

      <!-- List item ID of document -->
      <Field Name="ID">2</Field>

      <!-- Full URL to document -->
      <Field Name="FileRef">http://Server/FullUrl/File.doc</Field>

      <!-- New filename -->
      <Field Name="BaseName">NewName</Field>

   </Method>
</Batch>



回答2:


You should be able to use UpdateListItems. Here's an example.

Per comment: So the actual question is "how do I call a web service?" Take a look a this example. Some more good walkthroughs here.



来源:https://stackoverflow.com/questions/994173/how-do-i-rename-a-file-using-the-sharepoint-web-services

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