cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rolanddaane
Helper I
Helper I

update values of choice column in REST API

I'm trying to change the values of a choice field through the REST API of Sharepoint (I'm using Power Automate.

The flow executes without error, but the values don't change.
My library is test1 and the column is Originator.

Any help would be appreciated. Thanks in advance

rolanddaane_0-1637866727875.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @rolanddaane,

 

It looks like you can use a POST request (with MERGE in the header) against the specific field and use define the choices as xml.

 

I have tested below and that seems to work. Obviously test it first if this works for you as well.

 

{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose",
  "X-HTTP-Method": "MERGE"
}

 

{"__metadata":{"type":"SP.Field"},"SchemaXml":"<Field ClientSideComponentId='00000000-0000-0000-0000-000000000000' CustomFormatter='' DisplayName='Originator' FillInChoice='FALSE' Format='Dropdown' IsModern='TRUE' Name='Originator' Title='Originator' Type='Choice'><CHOICES><CHOICE>A</CHOICE><CHOICE>B</CHOICE></CHOICES></Field>","Title":"Originator","Description":""}

 

updatefield_merge.png

 

 

View solution in original post

4 REPLIES 4
Expiscornovus
Super User
Super User

Hi @rolanddaane,

 

It looks like you can use a POST request (with MERGE in the header) against the specific field and use define the choices as xml.

 

I have tested below and that seems to work. Obviously test it first if this works for you as well.

 

{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose",
  "X-HTTP-Method": "MERGE"
}

 

{"__metadata":{"type":"SP.Field"},"SchemaXml":"<Field ClientSideComponentId='00000000-0000-0000-0000-000000000000' CustomFormatter='' DisplayName='Originator' FillInChoice='FALSE' Format='Dropdown' IsModern='TRUE' Name='Originator' Title='Originator' Type='Choice'><CHOICES><CHOICE>A</CHOICE><CHOICE>B</CHOICE></CHOICES></Field>","Title":"Originator","Description":""}

 

updatefield_merge.png

 

 

View solution in original post

Hi,
Thanks for this.
Do you know how I can find the field GUID? I saw that you added it.

I also noticed that my code creates a new column named Originator (which I didn't know was possible)

rolanddaane_0-1637943658294.png

 

rolanddaane
Helper I
Helper I

I filled in something that looks like a GUID, and I get the following error:
The parameter __metadata does not exist in method GetById.
clientRequestId: 8b36b980-75d0-44df-a742-be64da0ad90f
serviceRequestId: bbf506a0-20cf-3000-5fa3-71252c489668

rolanddaane
Helper I
Helper I

I got it to work....!! thanks to  
I needed to change the method to PATCH, and then I can ass the getByTitle('Originator'). see belos.

It's now working! thanks mate


rolanddaane_0-1637953631779.png

 

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Users online (1,851)