3

I'm trying to use Microsoft Flow and the Send an HTTP request to SharePoint action to deploy an SPFx application customizer to a modern team site.

I'm able to use the /_api/Site/UserCustomActions endpoint to list existing custom actions but keep getting errors when I try to create new using REST

Site address: https://contoso.sharepoint.com/sites/a-modern-team-site

Method: POST

Uri: /_api/Site/UserCustomActions

Headers:

  • Accept application/json; odata=verbose
  • Content-Type application/json; odata=verbose

Body:

{
    '__metadata': { 'type': 'SP.UserCustomAction' },
    "Location":"ClientSideExtension.ApplicationCustomizer",
    "Rights":"ManageWeb",
    "Title":"EnableTeamsApplicationCustomizer",
    "Name":"EnableTeamsApplicationCustomizer",  
    "ClientSideComponentId":"fa80f680-bda9-4c15-a8fe-4e86be0bf593", 
    "ClientSideComponentProperties":"{\"autoCreate\":\"true\"}"
}

Here's the error I keep getting. I have tried various encoding of the client side properties, omitted it, but no results. I have tried different variations of the http headers, both with odata=verbose and odata=nometadata. I keep getting the same error, but can't find anything explaining the error.

{
  "status": 400,
  "message": "An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected.\r\nclientRequestId: 43c303e3-4722-4b5e-a5b5-5fbcc686ec50\r\nserviceRequestId: 1b1e6c9e-a0a1-5000-f082-74dd369cc50f",
  "source": "https://contoso.sharepoint.com/sites/a-modern-team-site/_api/Site/UserCustomActions",
  "errors": [
    "-1",
    "Microsoft.SharePoint.Client.InvalidClientQueryException"
  ]

}

1
  • Thanks for posting though, saved me a lot of trial and error (the UserCustomActionCollection does not support the PUT method and I was wondering how to create actions then, now that I knew a simple POST works for you I tried it for myself and indeed it does :)
    – frevd
    Commented Oct 14, 2018 at 21:12

1 Answer 1

0

I finally figured out what was wrong. The "Rights" property doesn't take a string like "ManageWeb" but is an object with High and Low properties.

I had to either remove the property or define the High and Low permission mask bits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.