416 Error when initiating upload
I'm trying to initiate an upload by posting to:
/d2l/api/lp/(version)/(orgUnitId)/managefiles/file/upload
I'm including the required headers (with the actual token where the placeholder is):
{ 'Authorization': 'Bearer <TOKEN>', 'X-Upload-Content-Type': 'text/csv', 'X-Upload-Content-Length': '530', 'X-Upload-File-Name': 'upload_test.csv'}
However, I'm getting the following error: 416 Requested Range Not Satisfiable
And response.text reads:
{"detail":"The page cannot be displayed because the request range was not satisfiable."}
I can find no information about this error on the community (or anywhere else online). Does anyone have insight?
Answers
-
I believe I have this figured out. I'm using Python Requests, which automatically treats 308 responses as redirects. Including allow_redirects=False in my request prevents this, allowing me to get the upload key from the api response.