Vignesh Subramanian
Vignesh Subramanian

Reputation: 7289

sharepoint 2010 get value of choice field through api call

I have a sharepoint list ImageList, i have a column which stores its type

The column name is ImageType

the choices are "profile pic","thumbnail" etc

i want to fetch these choice values for this field

i tried accessing it using

http://myintranet:2010/sites/ImagesGallery/_vti_bin/listdata.svc/ImageList?$expand=ImageType

but it is not containing the choice values in it!

How can i get them?

Upvotes: 2

Views: 1535

Answers (1)

Vadim Gremyachev
Vadim Gremyachev

Reputation: 59358

The query:

http://myintranet:2010/sites/ImagesGallery/_vti_bin/listdata.svc/ImageList?$expand=ImageType

returns list items values for List resource only.

In order to retrieve field resource itself, the different endpoint have to be specified, in particular:

http://myintranet:2010/sites/ImagesGallery/_vti_bin/listdata.svc/ImageListImageType

It is assumed that list name is ImageList and field name is ImageType

Example

$.getJSON(endpointUrl)
.done(function(data)
{
    //print field choice options
    data.d.results.forEach(function(item){ 
       console.log(item.Value);
    });

})
.fail(function(error){
    console.log(JSON.stringify(error));
});

Upvotes: 2

Related Questions