PaulCr125
Based on the question you posted, my understanding is you want to use Microsoft Graph to upload a file to the SharePoint Online's document directory.If I misunderstood your question, please feel free let me know.
My initial suggestion is that you can try use this API: PUT https://graph.microsoft.com/v1.0/drives/{document directory's id}/root:/{Folder Name}/{File Name}:/content
.
Based on my test, we can create a stream of the file into the body of the request. And the steps of the solution resemble the following:
- Get the document directory's id by the API below:
https://graph.microsoft.com/v1.0/drives
The part of the response like this:
{
"createdDateTime": "2018-06-26T15:06:46Z",
"description": "",
"id": {the directory's id},
"lastModifiedDateTime": "2018-08-14T05:29:44Z",
"name": "Documents",
"webUrl": "https://XX.sharepoint.com/Shared%20Documents",
"driveType": "documentLibrary",
}
- Make a PUT request to the following URL:
https://graph.microsoft.com/v1.0/drives/{the directory's id}/root:/{Folder Name}/{File Name}:/content
Note: Before initiating this request, we should set two required headers:
1) Authorization
2) Content-Type
For more detail, we can refer to the content of 'Upload or replace the contents of a DriveItem' and the question on the StackOverflow.