1

Am quite new to REST API. Our is a SharePoint 2016 on premises environment. We have document library. This document library has a property of type 'Choice'. We added a document and set the value for choice column. Now we have to access the choice property value through REST API. We tried using below URL request in browser. It gives xml response and has Choice column value in it as;

<d:PropertyName>HR Dept</d:PropertyName>

http://websiteurl/_api/web/getFileByServerRelativeUrl('/root/test%20doc%20for%20PDF.pdf')/ListItemAllFields

Thus tried accessing the data through jquery

$.ajax(
    {
    url:"http://websitename/_api/web/getFileByServerRelativeUrl('/root/test%20doc%20for%20PDF.pdf')/ListItemAllFields",
    method:"GET",
    headers: {"Accept":"application/json; odata=verbose"},
    success: function(data){
    debugger;

    }
    }
    );

However not able to get required object details in the json response!

Kindly let know what we are missing / doing wrong.

Thank you

1

Googling got the resolution by appending the property name at the end of the URL

URL:

http://websitename/_api/web/getFileByServerRelativeUrl('/root/test%20doc%20for%20PDF.pdf')/ListItemAllFields/Propertyname

However would like to know how to get correct JSON object for All fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.