416 Error when initiating upload

James.C.331
James.C.331 Posts: 8 🌱
edited November 11 in Development

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

  • James.C.331
    James.C.331 Posts: 8 🌱

    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.

  • Sean.R.636
    Sean.R.636 Posts: 9 🌱

    Is there any chance you would be able to share your Python script or function calls? I am working on something very similar (uploading a file to a dropbox as feedback) and have been getting some related errors. That would be a huge help!