Since yesterday, the file upload api keeps returning 403 randomly. But it depends on the sharepoint. Many of our clients dont seem to encounter the issue, but our own sharepoint, and a new client's sharepoint have this problem.
Basically every upload request either succeeds or returns 403 Access denied error. And more often than not, it returns 403:
Here is an example of a request (client's sharepoint):
error: "{
↵ "error": {
↵ "code": "accessDenied",
↵ "message": "Access denied",
↵ "innerError": {
↵ "date": "2020-10-14T08:51:20",
↵ "request-id": "cacf89c3-5dbc-4390-98a1-5d7cb9e2668d",
↵ "client-request-id": "cacf89c3-5dbc-4390-98a1-5d7cb9e2668d"
↵ }
↵ }
↵}"
Another example (our sharepoint):
error: "{
↵ "error": {
↵ "code": "accessDenied",
↵ "message": "Access denied",
↵ "innerError": {
↵ "date": "2020-10-14T09:01:38",
↵ "request-id": "3c23f74d-579b-41e8-aafc-a6e3b3a6d885",
↵ "client-request-id": "3c23f74d-579b-41e8-aafc-a6e3b3a6d885"
↵ }
↵ }
↵}"
Nothing has been changed on our sharepoint, it used to always work, no code change, no configuration change on sharepoint.
Edit, code being used for upload:
private function uploadSmallFile(string $localFilePath, string $remoteFilePath, $conflictBehavior)
{
$route = "/sites/root/drive/items/root:$remoteFilePath:/content";
$route = $route . '[email protected]=' . $conflictBehavior;
$item = $this->client->createRequest('PUT', $route, true)
->setReturnType(Model\DriveItem::class)
->attachBody(file_get_contents($localFilePath))
->execute();
return $item;
}
Further details:
Accessing sharepoint on the browser works fine.
Using Insomnia (like Postman but for all uses), here is what happens with a path (Content-Type and Content-Length specified):
With itemId:
This is strange, because I'm pretty sure it's not code related, since this happens on a codebase thats as old as june 2020 and didn't change since then.
Edit: Problem seems to be solved, no code was changed on my side. API Related problem.
Edit 2: Problem is back as of today 20-10-2020 (at least since 8am CEST)