I have a document library which i am making a Ajax call to:
function GetAttachments(){
$.ajax({
url: "XXX_api/web/lists/GetByTitle('CM Attachments')/items?$top=5000",
type: "GET",
headers: {
accept: 'application/json',
},
success: function(data){
console.log('All docs below')
console.log(data)
},
error: function(data, error, err, errorCode, errorMessage){
console.log(data)
console.log(error)
console.log(err)
console.log(errorCode)
console.log(errorMessage)
}
})
}
When inspecting the console.log(data) it returns the array in JSON (as specified in my header) But i can't see any URL's related to the document, i have an odata.editLink: and GUID. Is there any way to return the actual URL of this document?
My reason for wanting this is so i can build a "document" list in a custom form i have. I will make a call inside the form to get the attachments and filter where ID is === to formID.
I'd then like to mimic the documents as attachments (will append an icon for each document, and pass the document URL as a href ) so when they are clicked are opened in a new window. Depending on the document type the outcome should either preview the document or download.
Any help is greatly appreciated.
Cheers.