I'm trying to upload a simple txt document to a sharepoint library, from power apps, using this tutorial.
I think I'm doing it right, troubleshooted a lot of permissions issues trough the process, but I got stuck in this error:
Unabel to read JSON request payload.
I'm just sending a put request using this:
Office365Groups.HttpRequest(
"https://graph.microsoft.com/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content:",
"PUT",
ThisRecord.Value
)
mySiteIdid
and myDriveId
, I got them both correct. ThisRecord.Value
is the file content from the attachment field.
I also get the same result if I try this on the Graph Explorer.
It clearly states in the documentation, that the payload should be text/plain.
It works fine if you remove :
of the url
/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content:
/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content
I would also set the Content-Type
parameter to text/plain
Office365Groups.HttpRequest(
"https://graph.microsoft.com/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content",
"PUT",
ThisRecord.Value,
"text/plain"
)