我正在尝试使用 SharePoint REST API更新列表项,但遇到以下错误:
<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-1, Microsoft.SharePoint.Client.InvalidClientQueryException</m:code>
<m:message xml:lang="en-US">The expression "web/lists/GetByTitle('Drop Off Library')/items("http:/example.com/_api/Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')")" is not valid.</m:message>
</m:error>
添加文件后,我收到以下响应:
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="http://example.com/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
<id>http://example.com/_api/Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')</id>
<category term="SP.File" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author" type="application/atom+xml;type=entry" title="Author" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')/Author" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CheckedOutByUser" type="application/atom+xml;type=entry" title="CheckedOutByUser" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')/CheckedOutByUser" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/EffectiveInformationRightsManagementSettings" type="application/atom+xml;type=entry" title="EffectiveInformationRightsManagementSettings" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')/EffectiveInformationRightsManagementSettings" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/InformationRightsManagementSettings" type="application/atom+xml;type=entry" title="InformationRightsManagementSettings" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')/InformationRightsManagementSettings" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ListItemAllFields" type="application/atom+xml;type=entry" title="ListItemAllFields" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')/ListItemAllFields" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/LockedByUser" type="application/atom+xml;type=entry" title="LockedByUser" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')/LockedByUser" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')/ModifiedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Properties" type="application/atom+xml;type=entry" title="Properties" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')/Properties" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Versions" type="application/atom+xml;type=feed" title="Versions" href="Web/GetFileByServerRelativeUrl('/DropOffLibrary/b.txt')/Versions" />
<title />
<updated>2019-01-11T14:47:13Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:CheckInComment></d:CheckInComment>
<d:CheckOutType m:type="Edm.Int32">0</d:CheckOutType>
<d:ContentTag>{2BDD4E2D-79C8-4F6B-8DD7-AC745D9360A8},1,1</d:ContentTag>
<d:CustomizedPageStatus m:type="Edm.Int32">0</d:CustomizedPageStatus>
<d:ETag>"{2BDD4E2D-79C8-4F6B-8DD7-AC745D9360A8},1"</d:ETag>
<d:Exists m:type="Edm.Boolean">true</d:Exists>
<d:IrmEnabled m:type="Edm.Boolean">false</d:IrmEnabled>
<d:Length m:type="Edm.Int64">4</d:Length>
<d:Level m:type="Edm.Byte">255</d:Level>
<d:LinkingUrl></d:LinkingUrl>
<d:MajorVersion m:type="Edm.Int32">1</d:MajorVersion>
<d:MinorVersion m:type="Edm.Int32">0</d:MinorVersion>
<d:Name>b.txt</d:Name>
<d:ServerRelativeUrl>/DropOffLibrary/b.txt</d:ServerRelativeUrl>
<d:TimeCreated m:type="Edm.DateTime">2019-01-11T14:47:13Z</d:TimeCreated>
<d:TimeLastModified m:type="Edm.DateTime">2019-01-11T14:47:13Z</d:TimeLastModified>
<d:Title m:null="true" />
<d:UIVersion m:type="Edm.Int32">512</d:UIVersion>
<d:UIVersionLabel>1.0</d:UIVersionLabel>
<d:UniqueId m:type="Edm.Guid">2bdd4e2d-79c8-4f6b-8dd7-ac745d9360a8</d:UniqueId>
</m:properties>
</content>
</entry>
我在这里的假设是,项目 id 要么是<id>
标签的值,要么是标签的值<UniqueId>
,但都没有奏效。