1

I am trying to upload a file to the Shared Documents library of my SharePoint website. The files are of type PDF and HTML. I am running a Cold Fusion development environment and using CFHTTP commands to execute HTTP requests. I have been able push a POST command and a PUT command to the proper endpoints listed on this link below:

Link: https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#best-practices

I do not understand why but the first section that mentions the HTTP requests for creating an upload session is different than what was used in the example a little further. For my project, I am using the endpoint:

"/{variables.instance.microsoftGraphAPIURL}/drive/root:/{item-path}:/createUploadSession"

P.S. variables.instance.microsoftGraphAPIURL is a variable to a microsoft graph endpoint to our Sharepoint website

With better luck using PUT commands than POST commands for creating an Upload Session. I am able to receive an uploadURL, but the issue comes with trying to upload the file. For the file upload, I am trying to upload a file in the same directory with a file size of 114992 bytes. I keep getting "The Content-Range header length does not match the provided number of bytes." whenever I run my Put command to upload the file.

Thus, my Content-Range is "bytes 0-114991/114992" and my Content-Length is "114992". For the image below, I replaced the file with a pdf, but the original file was an HTML page at 114992 bytes. I want to use a resumable upload session to have one function for uploading image, HTML, and PDF files.

enter image description here

If anyone could tell me if there is an issue with my content headers or my upload session http request or anything else that is causing my issue, that would be amazing! Thank you.

rrk
  • 15,677
  • 4
  • 29
  • 45
wchan1097
  • 11
  • 2
  • I found another MS page that has better documentation, but is still not spot-on. https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession?view=odsp-graph-online#create-an-upload-session You should only need to POST to createUploadSession (with only the auth header), then take the resulting uploadUrl and PUT chunks of the file there. So far I've been able to upload the entire file, surpassing MS Graph API's 4mb limit, but when trying to chunk it out I get the same result you do on the last step. (CF 4eva!) – St.G Sep 21 '22 at 20:30
  • I believe your key is in this statement: "Use a byte range size that is a multiple of 320 KiB (327,680 bytes). Failing to use a fragment size that is a multiple of 320 KiB can result in large file transfers failing after the last byte range is uploaded." – St.G Sep 21 '22 at 21:05
  • Hello. Thank you for responding to my question. What file type did you upload and what parameters did you use for the content length and content range? – wchan1097 Oct 14 '22 at 17:10
  • Hello. Disregard my last question. I did a dumb haha. I got it all figured out but thank you! – wchan1097 Oct 14 '22 at 21:04
  • I found that the browser handles all the chunking and whatnot when doing this client-side. Made that part of the job really easy! Glad you figured it out. – St.G Oct 15 '22 at 18:08
  • @wchan1097 - Would it be possible to provide the solution you came to please? You asked the question and then said you had it all figured out but didn't explain what the solution was. It would be very much appreciated if you could provide it as I have reached the exact same point as you but have not got it all figured out yet :-) Thank you. – Watts Epherson May 03 '23 at 15:31
  • @wchan1097 How did you solve this? I'm having the same issue. – MalcolmInTheCenter Jul 27 '23 at 20:37

0 Answers0