# Scenario

I have a Document library named "My Documents". In that library couple of folders, for these each folders have another couple of folders (subfolders) and inside these folders, certain documents. Requirements are that all these document id must be unique.

Now if I have the document id. How to get perticular document from its id? When the document is found I want the path to that document.

How do I accomplish that using Rest API?

Finally i found solution, i got full file url through EncodedAbsUrl

My Document id is 6 and got full filepath from its id

var requestUri = _spPageContextInfo.webAbsoluteUrl +
"/_api/web/lists/getByTitle('My Documents')/items?$select=EncodedAbsUrl&$filter=Id eq 6";

"accept": "application/json;odata=verbose"
}

$.ajax({ url: requestUri, type: 'GET', dataType: 'json', headers: requestHeaders, success: function (data) {$.each(data.d.results, function(i,result) {
var path = result.EncodedAbsUrl;
});

},
error: function ajaxError(response) {
alert(response.status + ' ' + response.statusText);
}
});


For retrieving document(s) by id, the best approach is to use filter parameter from MS Documentation.

Example :

**<url_SP_Site>**/_api/web/lists/getbytitle('**[Name_Document_Library]**')/items?$select=Id&$filter=Id eq '**[Id_you_search_for]**'


If you want to search for multiple documents ids, you can add 'and' or 'or' operators. (I think you have more operators, see the documentation)

Example :

**<url_SP_Site>**/_api/web/lists/getbytitle('[Name_Document_Library]')/items?$select=Id&$filter=Id eq '[Id_you_search_for]' **and** Id eq '[Another_Id_you_search_for]'

**<url_SP_Site>**/_api/web/lists/getbytitle('[Name_Document_Library]')/items?$select=Id&$filter=Id eq '[Id_you_search_for]' **or** Id eq '[Another_Id_you_search_for]'


After that you can use expand parameter with File value to have the relative URL :

**[url_SP_Site]**/_api/web/lists/getbytitle('[Name_Document_Library]')/items?$select=Id,**File/ServerRelativeUrl&$expand=File**&\$filter=Id eq '[Id_you_search_for]' **or** Id eq '[Another_Id_you_search_for]'


When you get the response encoded in JSON Format, you can access easily with :

**d/results([Your_Index])/File/ServerRelativeUrl**


I hope this help people =)

Please check the below link. I hope to be what you are searching for.

http://wmostafaw.wordpress.com/2014/01/01/get-document-path-serverrelativeurl-in-sharepoint-2013-using-rest-api/

• Please do not just post a link to your personal blog to drive traffic! Post the details here and point to your blogpost as Source – Robert Lindgren Jan 1 '14 at 12:10
• And also, the post in no way shows how to retrieve a document by its ID – Robert Lindgren Jan 1 '14 at 12:11
• thanks for your answer but not works – Hitesh Chandegara Jan 1 '14 at 13:55