Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to create upload session (Bad Request) #112

Open
istellas opened this issue Jan 7, 2022 · 10 comments
Open

[Bug]: Unable to create upload session (Bad Request) #112

istellas opened this issue Jan 7, 2022 · 10 comments
Labels
potential bug Bug reported but yet to be analysed

Comments

@istellas
Copy link

istellas commented Jan 7, 2022

Description of the bug

Backups don't get uploaded

Plugin version

1.0

OctoPrint version

1.7.2

OctoPrint logs

The errors from octoprint.log after the backup that was created successfully are the following. I also attach sysinfo bundle.
Can you see something that has to do with my setup?

octoprint-systeminfo-20220107183101.zip
2022-01-07 18:23:19,862 - octoprint.plugins.backup - INFO - ... done creating backup zip.
2022-01-07 18:23:19,868 - octoprint.plugins.onedrive_backup.OneDriveComm - INFO - Starting upload session for octoprint-backup-20220107-182319.zip
2022-01-07 18:23:20,726 - octoprint.plugins.onedrive_backup.OneDriveComm - ERROR - 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/me/drive/items/01ZXFHCG2P45CF7E6UHRFZ3ZXTOUSZNGGO:/octoprint-backup-20220107-182319.zip:/createUploadSession
Traceback (most recent call last):
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_onedrive_backup/onedrive.py", line 309, in _graph_request
response.raise_for_status()
File "/home/pi/oprint/lib/python3.7/site-packages/requests/models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/me/drive/items/01ZXFHCG2P45CF7E6UHRFZ3ZXTOUSZNGGO:/octoprint-backup-20220107-182319.zip:/createUploadSession
2022-01-07 18:23:20,731 - octoprint.plugins.onedrive_backup.OneDriveComm - ERROR - Error creating upload session: {'code': 'invalidRequest', 'message': 'Invalid request', 'innerError': {'date': '2022-01-07T16:23:20', 'request-id': '6ffcdfb8-85d5-4600-a9b1-34d4bf032e2a', 'client-request-id': '6ffcdfb8-85d5-4600-a9b1-34d4bf032e2a'}}

@cp2004
Copy link
Owner

cp2004 commented Jan 7, 2022

That URL looks to be formatted OK, although the folder ID that is being used (which would have been set when you configured the upload destination) looks a little different from mine. Mine is 23 characters whereas yours is 34, maybe something about the configuration of our accounts is different.

Is it a personal MS account, or a work/school etc. account? Have you tried with different folder upload paths as well? My solution may not be 100% bullet proof, if there is an issue such as someone having a shared drive or something it might be different. Nothing special about where you are trying to upload backups to?

@cp2004 cp2004 added the potential bug Bug reported but yet to be analysed label Jan 7, 2022
@istellas
Copy link
Author

istellas commented Jan 7, 2022

It is a work account. I have tried multiple folders (also one word folder name i.e. Octoprint) but with the same error. I have also tried sharing this folder with everyone. The access I have to this one drive account is read/write.

@cp2004
Copy link
Owner

cp2004 commented Jan 7, 2022

Work account could be the issue. The Microsoft graph API is not completely clear on what format the upload session URL should be in, if that is even the case. Logic would say that if you were able to list the folders to configure the path in the first place then the same format would also work for creating the upload session.

If I can figure out any possible changes I will have to ask you to test them.

@cp2004 cp2004 changed the title [Bug]: [Bug]: Unable to create upload session (Bad Request) Jan 7, 2022
@shakeandbake017
Copy link

i have the same issue, and Im also trying to use a onedrive account with a "work account".

@cp2004
Copy link
Owner

cp2004 commented Jan 7, 2022

Your one, @shakeandbake017 didn't seem to be able to get past selecting the folders (from the log in #113). In the other log in this ticket, there must have been something that worked for it to get the folder ID to upload to, because it can attempt an upload. Anyway, we will keep all the discussion in one place, it makes sense.

It might take me a while to get my head around any possible differences with the APIs....

@shakeandbake017
Copy link

Thank you in advance for looking into this! I can help with any testing along the way, and I'm definitely in no rush so take your time.

@istellas
Copy link
Author

istellas commented Jan 8, 2022

@cp2004 Sure I'd be glad to help!

@cp2004
Copy link
Owner

cp2004 commented Jan 15, 2022

I have been quite busy this week so progress looking at this is slow. But I will summarise my thoughts. I did perform some experiments using the Microsoft Graph Explorer, but everything seemed to work as expected for all the options I tried.

The API docs give 5 ways I can try and create an upload:

POST /drives/{driveId}/items/{itemId}/createUploadSession
POST /groups/{groupId}/drive/items/{itemId}/createUploadSession
POST /me/drive/items/{itemId}/createUploadSession
POST /sites/{siteId}/drive/items/{itemId}/createUploadSession
POST /users/{userId}/drive/items/{itemId}/createUploadSession

The plugin is using the /me one to get both the folder list (to display in the UI) and create the upload session (MS Graph Explorer Query), so my current theory is that your accounts don't have a storage drive owned by the account? Or no default place to put the files?
Maybe for some reason they don't like the /me endpoints, which makes configuring it more complicated since I will have to find a 'driveID' from somewhere to access the relevant drive.

I don't know enough about the way work accounts can be setup in Microsoft (though I have contact with people who do have them) to figure it out myself, so this might be a long project...

@istellas
Copy link
Author

istellas commented Jan 16, 2022 via email

@shakeandbake017
Copy link

I just wanted to provide a quick update, as my issues seem to be resolved. Part of it was an error on my part as well. I reinstalled the plugin today, and when I logged in I remembered my account is a bit split with work/school and personal accounts. Some of my accounts had already been setup before I merged it into my O365 domain. Anyway - this time, I logged in and selected personal instead of work/school. It let me go through the login process, and this time I actually was able to select a folder. I ran the backup and the upload succeeded, so it looks like my issue is at least resolved. Not sure if that is going to fix anyone else though, as it looks like my onedrive account is infact a personal account. The rest of my accounts (exchange, teams, sharepoint) all use work/school as the account. Same username and passwords.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Bug reported but yet to be analysed
Projects
None yet
Development

No branches or pull requests

3 participants