【问题标题】:How to set user field in SharePoint Online with Power Automate HTTP Request to _vti_bin/client.svc/ProcessQuery?如何使用 Power Automate HTTP 请求在 SharePoint Online 中将用户字段设置为 _vti_bin/client.svc/ProcessQuery?
【发布时间】:2021-09-17 04:30:24
【问题描述】:

我试图弄清楚如何使用 Power Automate 在 SharePoint 中设置用户字段值。我需要使用 SystemUpdate 方法,所以我不得不使用 CSOM XML 请求方法 (_vti_bin/client.svc/ProcessQuery) 但我无法让它工作..

使用 C# 和 fiddler 生成 XML 以查看请求的外观,我得到了这个:

<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName=".NET Library" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
<Actions>
    <Method Name="SetFieldValue" Id="41" ObjectPathId="30" Version="82">
        <Parameters>
            <Parameter Type="String">CosUser</Parameter>
            <Parameter TypeId="{c956ab54-16bd-4c18-89d2-996f57282a6f}">
                <Property Name="Email" Type="Null" />
                <Property Name="LookupId" Type="Int32">304</Property>
                <Property Name="LookupValue" Type="Null" />
            </Parameter>
        </Parameters>
    </Method>
    <Method Name="SystemUpdate" Id="42" ObjectPathId="30" Version="82" />
    <Query Id="43" ObjectPathId="30">
        <Query SelectAllProperties="false">
            <Properties>
                <Property Name="FileSystemObjectType" ScalarProperty="true" />
                <Property Name="Id" ScalarProperty="true" />
                <Property Name="ServerRedirectedEmbedUri" ScalarProperty="true" />
                <Property Name="ServerRedirectedEmbedUrl" ScalarProperty="true" />
                <Property Name="ContentTypeId" ScalarProperty="true" />
                <Property Name="_ModerationComments" ScalarProperty="true" />
                <Property Name="FileLeafRef" ScalarProperty="true" />
                <Property Name="Modified_x0020_By" ScalarProperty="true" />
                <Property Name="Created_x0020_By" ScalarProperty="true" />
                <Property Name="File_x0020_Type" ScalarProperty="true" />
                <Property Name="HTML_x0020_File_x0020_Type" ScalarProperty="true" />
                <Property Name="_SourceUrl" ScalarProperty="true" />
                <Property Name="_SharedFileIndex" ScalarProperty="true" />
                <Property Name="ComplianceAssetId" ScalarProperty="true" />
                <Property Name="Title" ScalarProperty="true" />
                <Property Name="TemplateUrl" ScalarProperty="true" />
                <Property Name="xd_ProgID" ScalarProperty="true" />
                <Property Name="xd_Signature" ScalarProperty="true" />
                <Property Name="_ShortcutUrl" ScalarProperty="true" />
                <Property Name="_ShortcutSiteId" ScalarProperty="true" />
                <Property Name="_ShortcutWebId" ScalarProperty="true" />
                <Property Name="_ShortcutUniqueId" ScalarProperty="true" />
                <Property Name="_dlc_DocId" ScalarProperty="true" />
                <Property Name="_dlc_DocIdUrl" ScalarProperty="true" />
                <Property Name="_dlc_DocIdPersistId" ScalarProperty="true" />
                <Property Name="Godk_x00e4_ndVersion" ScalarProperty="true" />
                <Property Name="Godk_x00e4_nt" ScalarProperty="true" />
                <Property Name="_ModerationStatus" ScalarProperty="true" />
                <Property Name="MediaServiceMetadata" ScalarProperty="true" />
                <Property Name="MediaServiceFastMetadata" ScalarProperty="true" />
                <Property Name="CosUser" ScalarProperty="true" />
                <Property Name="ID" ScalarProperty="true" />
                <Property Name="Created" ScalarProperty="true" />
                <Property Name="Author" ScalarProperty="true" />
                <Property Name="Modified" ScalarProperty="true" />
                <Property Name="Editor" ScalarProperty="true" />
                <Property Name="_HasCopyDestinations" ScalarProperty="true" />
                <Property Name="_CopySource" ScalarProperty="true" />
                <Property Name="FileRef" ScalarProperty="true" />
                <Property Name="FileDirRef" ScalarProperty="true" />
                <Property Name="Last_x0020_Modified" ScalarProperty="true" />
                <Property Name="Created_x0020_Date" ScalarProperty="true" />
                <Property Name="File_x0020_Size" ScalarProperty="true" />
                <Property Name="FSObjType" ScalarProperty="true" />
                <Property Name="SortBehavior" ScalarProperty="true" />
                <Property Name="CheckedOutUserId" ScalarProperty="true" />
                <Property Name="IsCheckedoutToLocal" ScalarProperty="true" />
                <Property Name="CheckoutUser" ScalarProperty="true" />
                <Property Name="UniqueId" ScalarProperty="true" />
                <Property Name="SyncClientId" ScalarProperty="true" />
                <Property Name="ProgId" ScalarProperty="true" />
                <Property Name="ScopeId" ScalarProperty="true" />
                <Property Name="VirusStatus" ScalarProperty="true" />
                <Property Name="CheckedOutTitle" ScalarProperty="true" />
                <Property Name="_CheckinComment" ScalarProperty="true" />
                <Property Name="MetaInfo" ScalarProperty="true" />
                <Property Name="_Level" ScalarProperty="true" />
                <Property Name="_IsCurrentVersion" ScalarProperty="true" />
                <Property Name="ItemChildCount" ScalarProperty="true" />
                <Property Name="FolderChildCount" ScalarProperty="true" />
                <Property Name="Restricted" ScalarProperty="true" />
                <Property Name="OriginatorId" ScalarProperty="true" />
                <Property Name="NoExecute" ScalarProperty="true" />
                <Property Name="ContentVersion" ScalarProperty="true" />
                <Property Name="_ComplianceFlags" ScalarProperty="true" />
                <Property Name="_ComplianceTag" ScalarProperty="true" />
                <Property Name="_ComplianceTagWrittenTime" ScalarProperty="true" />
                <Property Name="_ComplianceTagUserId" ScalarProperty="true" />
                <Property Name="BSN" ScalarProperty="true" />
                <Property Name="_ListSchemaVersion" ScalarProperty="true" />
                <Property Name="_Dirty" ScalarProperty="true" />
                <Property Name="_Parsable" ScalarProperty="true" />
                <Property Name="_StubFile" ScalarProperty="true" />
                <Property Name="_HasEncryptedContent" ScalarProperty="true" />
                <Property Name="AccessPolicy" ScalarProperty="true" />
                <Property Name="_VirusStatus" ScalarProperty="true" />
                <Property Name="_VirusVendorID" ScalarProperty="true" />
                <Property Name="_VirusInfo" ScalarProperty="true" />
                <Property Name="_CommentFlags" ScalarProperty="true" />
                <Property Name="_CommentCount" ScalarProperty="true" />
                <Property Name="_LikeCount" ScalarProperty="true" />
                <Property Name="_RmsTemplateId" ScalarProperty="true" />
                <Property Name="_IpLabelId" ScalarProperty="true" />
                <Property Name="_DisplayName" ScalarProperty="true" />
                <Property Name="_IpLabelAssignmentMethod" ScalarProperty="true" />
                <Property Name="A2ODMountCount" ScalarProperty="true" />
                <Property Name="AppAuthor" ScalarProperty="true" />
                <Property Name="AppEditor" ScalarProperty="true" />
                <Property Name="SMTotalSize" ScalarProperty="true" />
                <Property Name="SMLastModifiedDate" ScalarProperty="true" />
                <Property Name="SMTotalFileStreamSize" ScalarProperty="true" />
                <Property Name="SMTotalFileCount" ScalarProperty="true" />
                <Property Name="owshiddenversion" ScalarProperty="true" />
                <Property Name="_UIVersion" ScalarProperty="true" />
                <Property Name="_UIVersionString" ScalarProperty="true" />
                <Property Name="InstanceID" ScalarProperty="true" />
                <Property Name="Order" ScalarProperty="true" />
                <Property Name="GUID" ScalarProperty="true" />
                <Property Name="WorkflowVersion" ScalarProperty="true" />
                <Property Name="WorkflowInstanceID" ScalarProperty="true" />
                <Property Name="ParentVersionString" ScalarProperty="true" />
                <Property Name="ParentLeafName" ScalarProperty="true" />
                <Property Name="DocConcurrencyNumber" ScalarProperty="true" />
                <Property Name="ParentUniqueId" ScalarProperty="true" />
                <Property Name="StreamHash" ScalarProperty="true" />
            </Properties>
        </Query>
    </Query>
</Actions>
<ObjectPaths>
    <Identity Id="30" Name="70a7809f-e0f1-2000-3b39-606f7342ba2c|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:c8820382-1e83-42c7-81ba-911b2588b810:web:91a8bac3-5a81-47bb-abea-5797f7a4f9f8:list:ea4b0053-df63-468f-8e89-45891e1b68a2:item:1,1" />
</ObjectPaths>

但如果我在 Power Automate 中使用该 XML,它会抛出这个:

[
  {
    "SchemaVersion": "15.0.0.0",
    "LibraryVersion": "16.0.20523.12005",
    "ErrorInfo": {
      "ErrorMessage": "Unknown error",
      "ErrorValue": null,
      "TraceCorrelationId": "6205819f-b00a-2000-4281-194024f5ab40",
      "ErrorCode": -1,
      "ErrorTypeName": "Microsoft.SharePoint.Client.UnknownError"
    },
    "TraceCorrelationId": "6205819f-b00a-2000-4281-194024f5ab40"
  }
]

我正在使用这个标题:

Content-Type: text/xml
X-Requested-With: XMLHTTPRequest
Accept: */*

我到处寻找解决方案,但没有找到任何解决方案。有人知道如何使用 CSOM XML 设置用户字段吗?

【问题讨论】:

  • 这里有同样的问题。之后有什么解决办法吗?

标签: xml sharepoint-online csom power-automate


【解决方案1】:

我自己也遇到了类似的问题,我的解决方案是在我的目标列表上使用 F12 开发者工具网络选项卡 + SPO 现代体验“在网格视图中编辑”,看看它如何使用 _vti_bin/client.svc/ProcessQuery 更新一个人/group 字段。

以下是我在 Power Automate 中更新单个列表项的方法:

操作:Send an HTTP Request to SharePoint

方法:POST

Uri:_vti_bin/client.svc/ProcessQuery

标题:

Content-Type: text/xml;charset="UTF-8"
X-Requested-With: XMLHTTPRequest
Accept: */*

主体:

<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="Javascript Library">
    <Actions>
        <Method Name="SetFieldValue" Id="19" ObjectPathId="3">
            <Parameters>
                <Parameter Type="String">YourPersonField</Parameter>
                <Parameter Type="String">-1;#someone@yourorg.onmicrosoft.com</Parameter>
            </Parameters>
        </Method>
        <Method Name="SystemUpdate" Id="5" ObjectPathId="3" />
    </Actions>
    <ObjectPaths>
        <Property Id="1" ParentId="0" Name="Web" />
        <Method Id="2" ParentId="1" Name="GetList">
            <Parameters>
                <Parameter Type="String">/sites/YourSite/YourList</Parameter>
            </Parameters>
        </Method>
        <Method Id="3" ParentId="2" Name="GetItemById">
            <Parameters>
                <Parameter Type="Number">YourListItemID</Parameter>
            </Parameters>
        </Method>
        <StaticProperty Id="0" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" />
    </ObjectPaths>
</Request>

图片:

【讨论】:

    【解决方案2】:

    解决您的问题的方法可能很简单:只需从您的 xml 请求中删除空格和换行符即可。


    nearbaseline.com 上有一篇关于此的不错的博客文章。回答您的问题的陈述可以在该文章的中间找到:

    重要提示:请注意,我已经去除了 XML 中的制表符、空格和行尾!这是必需的,如果您不这样做,您将在较大的查询正文中收到未知错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-21
      • 2021-06-15
      • 1970-01-01
      • 2022-01-17
      • 2013-07-08
      • 2021-05-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多