I'm trying to find a way to get a value for my field which is based on a GlobalOptionSet. I'm managing to pull back data from my endpoint https://TEST.test.dynamics.com/api/data/v9.1/projects which is returning my list of projects. some of the fields on this dataset just show as GUID's which I've managed to expand into and get their values. However, some of the fields returned are showing just numbers like 866110000 which I believe is an option in a GlobalOptionSet.
I know I can get the GlobalOptionSet definition and match up its value but I'm hoping to be able to get this information in a single query similar to the way I got other fields by expanding.
Does anyone know how to get it to return the selected Value for an option field instead of the ID of the option that was picked?
Thanks
All you have to do is include the below header to get the needed optionset & lookup display name values. Read more
Prefer: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Sample request:
GET [Organization URI]/api/data/v9.1/accounts?$select=name,donotpostalmail,accountratingcode,numberofemployees,revenue
&$top=1 HTTP/1.1
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
Prefer: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
If its AJAX request using jQuery or XmlHttpRequest, for ex.
req.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue");