0

We have a choice field in a document library that is made up of 30 values and would like to know if there is any calls that can be made via RestFUL API to retrieve all possible values?

We have an application that would upload documents to SharePoint via RestFUL and need to ensure that the choice field values are synchronized.

Our choice field is like:

  • Description Category 1 <1>
  • Description Category 2 <2>
  • Description Category 3 <3>

Any help would be appreciated!

0

To get all choices with REST API:

site column:

http://<site url>/_api/web/fields/getByInternalNameOrTitle('fieldInternalName')

list column:

http://<site url>/_api/web/lists(listid)/fields/getByInternalNameOrTitle('fieldInternalName')

Official documentation

  • Thanks for the reply, would the internal name be something like "Category_x0020_abbr_x002e_"? Sorry I am new to SharePoint RestFUL so please excuse any mundane queries – kacheung1000 Apr 4 at 7:19
  • Yes it could be. Go to List Settings, select a field and check URL – RiccardoGDev Apr 4 at 7:30
  • I've got limited access and cannot access List Settings. Though from SharePoint I can view the source and see the FieldInternalName. However when I try using the API it returns with: "Column 'Category_x0020_abbr_x002e_' does not exist. It may have been deleted by another user." Could it be access control problem? – kacheung1000 Apr 4 at 7:35
  • Are you using site column or list column? I've updated my answer with both cases and link official documentation – RiccardoGDev Apr 4 at 7:41
  • 1
    Hi, the method using the list by column worked! Many thanks for your help :) – kacheung1000 Apr 4 at 7:58
0

You can use below.

List Name is 'Temp' and Column Name is 'My Choice'

  /sites/sc1/_api/Web/Lists/getbyTitle(@v0)/Fields/getbyTitle(@v1)/Choices?&@v0='Temp'&@v1='My Choice'

Below is response you will get

> {   "d": {
>     "Choices": {
>       "__metadata": {
>         "type": "Collection(Edm.String)"
>       },
>       "results": [
>         "Choice #1",
>         "Choice #2",
>         "Choice #3"
>       ]
>     }   }

Also check if you have required access, as you are querying list columns you should be having access to list settings.

Hope this helps...!!!

0

Please try this. replace the SiteURL to your site url and List Name to your list name and Column to your desired column name.

Https://SiteURL/_api/Web/Lists/GetByTitle('ListName')/fields/getByInternalNameOrTitle('ColumnName')

This will display all the choice columns values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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