403 Forbidden Response using AAD App and SharePoint Graph API

Occasional Contributor

As the subject says, I am trying to upload a file to SharePoint Online Documnet library. 


I created AAD App and given Site.FullControl.All on my test lab tenant. I am able to generate oAuth Token but whenever I try to trigger the Invoke-RESTMethod it throws 403 error.

$Uri = #$Uri = "https://graph.microsoft.com/v1.0/drives/$driveId/items/root:/test45.docx:/content"

Invoke-RestMethod -Uri $Uri -Headers $headers -Method Put -Body $path.OpenRead() -ContentType "application/docx"


I tested the end point using the token available in Graph Explorer and it works fine. 


Any help.








1 Reply
Invoke-RestMethod : The remote server returned an error: (403) Forbidden.