How to access a doc's URL using REST API + JQuery in SharePoint 2013?

api, jquery, sharepoint

Solution

For the full url, try:

"http://sp2013/_api/Web/Lists/getByTitle('Documents')/items?$select=EncodedAbsUrl"

Problem

I am doing basic OData/REST calls to a SP2013 doc library. I am trying to get down to the item's URL and can't determine how to do this. I am very familiar with the server-side object model and understand that the file object is one level deeper than the item. Can someone point me in the right direction or share documentation on how to get down to the file level? I have scoured google. Here's my code that works for simply getting access to all the items in doc library and any metadata columns I wish to target: ``` <html> <head> <script src="http://code.jquery.com/jquery-latest.min.js"></script> </head> </html> <script> // workaround for access error jQuery.support.cors = true; // create REST query var requestUri = "http://sp2013/_api/Web/Lists/getByTitle('Documents')/items"; // execute AJAX request $.ajax({ url: requestUri, type: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function(data){ alert(data.d.results); $.each(data.d.results, function(index, item){ if (item["Meta1"] == null) { $("body").append("<h1>No Title</h1>"); } else { $("body").append("<h1>" + item["Meta1"] + "</h1>"); } }); }, error: function(jqXHR, textStatus, errorThrown){ alert(textStatus); } }); </script> ```

Original source