416 Error when initiating upload

James.C.331
James.C.331 Posts: 8 🌱
edited November 2025 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!

  • Ajith.J.824
    Ajith.J.824 Posts: 38 🤝🏼 image

    I’m unable to provide the Python script, but since there hasn’t been a response yet, I wanted to close the loop for anyone encountering this issue in the future. If you see the error:

    {"detail":"The page cannot be displayed because the request range was not satisfiable."}

    in Postman, when initiating an upload, the likely cause is redirect-follow behavior. Postman automatically follows the 308 Resume Incomplete response as a redirect, which leads to an invalid range request.

    Fix:

    • Disable “Follow redirects” for this request (go to the request → Settings tab).
    • Send the request again and inspect the first response, specifically:
      • Status Code (should be 308 Resume Incomplete)
      • Location header

    More details on resumable uploads can be found here:
    https://docs.valence.desire2learn.com/basic/fileupload.html#resumable-uploads

    I hope this helps!