To get the choice values from listdata.svc
you need to make a request against the correct EntitySet
...
You can think of an EntitySet
as any list that listdata.svc
has access to -- this includes choice field choices.
Choice field EntitySets will typically have an endpoint name that looks like:
<ListName><ChoiceFieldName>
So if I have a list called MyList
which has a choice field called MyChoiceField
, then a call to the entity set name that can be accessed by listdata.svc
would be have an endpoint of:
_vti_bin/listdata.svc/MyListMyChoiceField
To find the precise name of the EntitySet
you should be looking for, make a call to the top level endpoint listdata.svc
in the site you're interested in.
Use something like:
$.getJSON('../_vti_bin/listdata.svc').then(function(data) { console.log(data) });
In your browser dev tools console, expand the result object. The results should be alphabetical by default, find your list name then below it you should see some more choices for choice fields within that specific list.
When you locate the correct endpoint name, just make a call to that EntitySet
name like:
$.getJSON('../_vti_bin/listdata.svc/MyListMyChoiceField')
.then(function(data) { console.log(data) });
The results to the call against the choice field endpoint will give you a results
object which is an Array of objects representing the available choices for that field. You can access the values of the choices by using data.d.results[i].Value
in the callback.