Forum Discussion
Sandy5k
Jan 16, 2019Copper Contributor
Add a new choice option to a Choice site column in SharePoint Online using SharePoint REST API
Hi!
I am trying to add a new choice option to a Choice site column in SharePoint Online using SharePoint REST API. The choice site column is added to a content type and the content type is added to a SharePoint List.
While I am able to add a new choice option to the site column using below REST API, the changes are not pushed to the SharePoint List when updating a site column. Am I missing something here or is there a way to trigger the update to push the changes to all list columns based on this site column?
REST EndPoint - https://abc.sharepoint.com/_api/web/fields('guid')
Body - {"__metadata": {"type": "SP.FieldChoice"},
"Choices": {"__metadata": {"type": "Collection(Edm.String)"},
"results": ["Choice1",
"Choice2",
"Choice3",
"Choice4",
"New Choice"]
}}
CSOM has updateAndPushChanges method to trigger the update. However I am unable to find equivalent REST endpoint.
https://abc.sharepoint.com/_api/web/fields('guid')/updateandpushchanges(true) returns the following
{
"error": {
"code": "-1, Microsoft.SharePoint.Client.ResourceNotFoundException",
"message": {
"lang": "en-US",
"value": "Cannot find resource for the request updateAndPushChanges."
}
}
}
3 Replies
Sort By
- Eva VogelSteel Contributor
Hi Sandy5k,
The GUID is a protected column. I found an interesting tutorial for you with several steps to use it anyway, look at this.
Hope that helps. Greets, Eva.
- Chris GrayCopper Contributor