문제

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

This is what I have tried:

http://<sitecollection>/<site>/_api/web/contenttypes
도움이 되었습니까?

해결책

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'

다른 팁

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"
    ]
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top