title: How to upload a file to OneDrive using OneDrive REST API?
body: <p>Please allow me to explain <strong>what</strong> I am doing and <strong>How</strong> I am doing.</p>
  
  <p><strong>What I am doing?</strong></p>
  
  <p>I am trying to upload a file to Onedrive using its REST API
  Source: <a href="https://dev.onedrive.com/items/upload_large_files.htm" rel="noreferrer">one drive api documentation</a></p>
  
  <p>I am using OneDrive fragments approch to do so as the file can be as huge as 5gb or as small as 1kb (Depends on the user)</p>
  
  <p>Currently, I am doing it using <a href="https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en" rel="noreferrer">POST-MAN</a> Chrome extention to call APIes</p>
  
  <p><strong>How am I doing?</strong></p>
  
  <ol>
  <li>Generated Access token</li>
  <li>Created Session and received Uploading url</li>
  <li>Uploading file using PUT request as given below</li>
  </ol>
  
  <p>Selected file that I want to upload <em>(File Size: 729676295 bytes)</em>
  <a href="https://i.stack.imgur.com/Fberp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Fberp.png" alt="enter image description here"></a></p>
  
  <p>Added headers and sent the request and sent the request
  <a href="https://i.stack.imgur.com/WkVKn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WkVKn.png" alt="enter image description here"></a>
  <strong>Here is the result</strong>
  <a href="https://i.stack.imgur.com/wDQfj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wDQfj.png" alt="enter image description here"></a></p>
  
  <p>it is saying that the maximum fragment size is 67108864 bytes so I changed the value of </p>
  
  <p><strong>content-length : 67108864</strong> and
  <strong>content-range : bytes 0-67108863/729676295</strong></p>
  
  <p>but then I get this error message: <strong>Declared fragment length does not match the provided number of bytes</strong>
  <a href="https://i.stack.imgur.com/ZnoV5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZnoV5.png" alt="enter image description here"></a></p>
  
  <p><strong><em>Please help me to figure out what should I pass in content-length and content-range.</em></strong> </p>
  
  <p>Many Thanks for you attention.</p>