Question

How will I fetch choice field values from site content type directly>

This is what I have tried:

http://<sitecollection>/<site>/_api/web/contenttypes
Was it helpful?

Solution

If you know the names of your site columns then you can get choices for choice column direct using fields endpoint on web.

/_api/web/fields?$select=Choices&$filter=Title eq 'ChoiceCol'

OTHER TIPS

Assuming you know content type ID or title on which you you need find all Choice fields

Query first content type and its fields whose type is choice. Below is example of ContentType Tasks and using filter we are getting only Fields of type Choice

/sites/yoursc/_api/Web/ContentTypes(@v0)/Fields?&@v0='0x0108'&$select=ID,StaticName,Title, TypeAsString&$filter=TypeAsString eq 'Choice'

enter image description here

Now you can loop through above fields to target your specific field with ID. Below is URI for TaskStatus column

 /sites/mysc/_api/Web/AvailableFields(@v0)?&@v0=guid'c15b34c3-ce7d-490a-b133-3f4de8801b76'

You will get output as below

{
    "__metadata": {
        "type": "Collection(Edm.String)"
    },
    "results": [
        "Not Started",
        "In Progress",
        "Completed",
        "Deferred",
        "Waiting on someone else"
    ]
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top