I have one document library, in that, I have multiple folders.
For example:
- Foldername1/Foldername2/Foldername3/Text.docx
- Foldername1/Text.docx
- Foldername1/foldernmae2/Text.docx
In which folder user want to upload document they can upload.
In this images inside 18 Folder I am having Award, Closeout, and rfp. Inside these 3, I have Documents, Miscellneous, Request for proposal. Inside this I have 64 and 67.
I want to retrive the file from particular folder passing Foldernames
This is my code :
function GetDocumentName(strContractNumber, strChecklistName) {
//in this url i want to pass strContractNumber and strChecklistName
url = '/_api/web/lists/getbytitle(\'Documents\')/Items?$expand=Folder&$select=FileLeafRef,FileRef&$filter=FileLeafRef eq \'' + strContractNumber + '\'';
alert(url)
$.ajax({
type: 'GET',
headers: {
'accept': 'application/json;odata=verbose'
},
async: false,
url: url,
success: function (data) {
$.each(data.d.results, function (index, item) {
var s = item.FileLeafRef;
});
},
error: function (data) {
}
});
}
In the url, I have to pass the strContractNumber(18) and strChecklistName(Award). Now I want to get the Test.docx document name and store that document name in one string.
I tried this but is not working
url = '/_api/Web/GetFolderByServerRelativeUrl(\'Documents\')/Folders';
How can i acheive this?