I'm trying to figure out how to set a user field value in SharePoint with Power Automate. I need to use the SystemUpdate method so I'm forced to use the CSOM XML Request approach (_vti_bin/client.svc/ProcessQuery) but I can't make it work..
Using C# and fiddler to generate an XML to see how the request looks, I get this:
<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>
But if I use that XML in Power Automate, it throws me this:
[
{
"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"
}
]
I'm using this headers:
Content-Type: text/xml
X-Requested-With: XMLHTTPRequest
Accept: */*
I have searched everywhere for a solution, but have not found any. Anyone knows how to set a user field with CSOM XML?
The solution to your problem may be trivial: Just remove spaces and newlines from your xml request.
There's a nice blog entry at nearbaseline.com about that. The statement answering to your problem can be found in the middle of that article: