What will be the rest api query to get field values from site content type using rest api?
-
07-02-2021 - |
Frage
How will I fetch choice field values from site content type directly>
This is what I have tried:
http://<sitecollection>/<site>/_api/web/contenttypes
Lösung
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'
Andere Tipps
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'
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"
]
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange