Aug 07 2020 12:21 PM - edited Aug 07 2020 12:31 PM
I have created a file in OneDrive using
PUT /me/drive/root:{item-path}:/content
For example, I am using the following code:
fetch(`https://graph.microsoft.com/v1.0/me/drive/root:/gcFile.txt:/content`, {
method: "PUT",
mode: "cors",
cache: "no-cache",
headers: {
"Content-Type": "text/plain",
"Authorization": "Bearer " + this.token,
},
body: "This is the contents of a new file.",
});
This works fine. I can view the file and its contents using a web browser.
However, if I attempt to get the contents of the file using
GET /me/drive/root:/{item-path}:/content
it fails with the error
GET https://graph.microsoft.com/v1.0/me/drive/root:/gcFile.txt:/content 401 (Unauthorized)
For example, I am using the following code:
fetch(`https://graph.microsoft.com/v1.0/me/drive/root:/gcFile.txt:/content`, {
method: "GET",
mode: "no-cors",
cache: "no-cache",
headers: {
"Content-Type": "text/plain",
"Authorization": "Bearer " + this.token,
},
});
Does anyone know what I am doing wrong?
Is this the same problem as what is described in
https://docs.microsoft.com/en-us/sharepoint/troubleshoot/lists-and-libraries/401-error-when-using-gr...
?
If so, is there any other workaround that does not involve changing the conditional access in the Azure Active Directory?
Aug 08 2020 11:40 AM
SolutionAug 08 2020 11:40 AM
Solution