note: I've also posted this on stack overflow, I will share the answer there if I can get one. All data and images have been "sanitized" to remove any identifying info
For some context, I am using sp-rest-proxy to make a tool which will get, modify and replace json data from SharePoint (MS 365) with a react interface. After figuring out the authentication issues I now have this issue preventing me from updating files.
sp-rest-proxy comes with a very handy interface that let's you test out various routes on localhost, the chunks below are the SharePoint REST relative endpoints. Also, though I am using example paths for privacy purposes, there are no special characters in the real ones, it's not that "%" issue.
This endpoint works great, gives me the data with no fuss.
/sites/front/_api/web/GetFileByServerRelativeUrl('sites/homePage/DivisionSite/DeptSite/myLibrary/folder/subFolder/data.json')/$value
but these result in 404s
/sites/front/_api/web/GetFolderByServerRelativeUrl('sites/homePage/DivisionSite/DeptSite/myLibrary/folder/subFolder')/files/add(url='data.json',overwrite=true)
/sites/front/_api/web/GetFolderByServerRelativeUrl('sites/homePage/DivisionSite/DeptSite/myLibrary/folder/subFolder')/Files('data.json')
/*
{
"readyState": 4,
"responseText": "{\"error\":{\"code\":\"-2147024893, System.IO.DirectoryNotFoundException\",\"message\":{\"lang\":\"en-US\",\"value\":\"File Not Found.\"}}}",
"responseJSON": {
"error": {
"code": "-2147024893, System.IO.DirectoryNotFoundException",
"message": {
"lang": "en-US",
"value": "File Not Found."
}
}
},
"status": 404,
"statusText": "Not Found"
}
*/
I can use the interface to see that my folder exist and contains items (my json files)
/sites/front/_api/web/GetFolderByServerRelativeUrl('sites/homePage/DivisionSite/DeptSite/myLibrary/folder/subFolder')
/*
"..." represents stuff I hid for privacy
{
"d": {
"__metadata": {
"id": "...",
"uri": "...",
"type": "SP.Folder"
},
"Files": {
"__deferred": {
"uri": "..."
}
},
"ListItemAllFields": {
"__deferred": {
"uri": "..."
}
},
"ParentFolder": {
"__deferred": {
"uri": "..."
}
},
"Properties": {
"__deferred": {
"uri": "..."
}
},
"StorageMetrics": {
"__deferred": {
"uri": "..."
}
},
"Folders": {
"__deferred": {
"uri": "..."
}
},
"Exists": true,
"IsWOPIEnabled": false,
"ItemCount": 5,
"Name": "otherFolder",
"ProgID": null,
"ServerRelativeUrl": "sites/homePage/DivisionSite/DeptSite/myLibrary/folder/subFolder",
"TimeCreated": "2021-09-20T18:51:29Z",
"TimeLastModified": "2021-10-01T20:03:03Z",
"UniqueId": "...,
"WelcomePage": ""
}
}
*/
However, when I try to view files...
/sites/front/_api/web/GetFolderByServerRelativeUrl('sites/homePage/DivisionSite/DeptSite/myLibrary/folder/subFolder')/Files
/*
{
"d": {
"results": []
}
}
*/
My app permissions are set as follows: (as suggested here)
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />
</AppPermissionRequests>
as well as some visual that may help.