Hi @anna,
The error response indicates that you are trying to create an upload session on a folder instead of a file. Uploading files using an upload session is usually done for individual files, not for folders.
Here it is recommended to use the path:
https://graph.microsoft.com/v1.0/drives/root:/Documents/55/filename1.txt:/createUploadSession
Here is a test for your reference:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards
Cheng Feng