title: Upload PDF to OneDrive Microsoft Graph Rest API
body: <p>I would like to use JavaScript to upload a PDF file to my SharePoint Office 365 site. I have been able to 
  - Authenticate and received Token
  - Use example to create a plain text file</p>
  
  <p>I would like to upload a PDF file onto SharePoint. I have tried converting the file to binary and to base64 but the resultant file appears to be a text file. </p>
  
  <pre><code>var xhr = new ActiveXObject("Microsoft.XMLHTTP");
  url = "https://graph.microsoft.com/beta/drive/root:/test10.pdf:/content"
  xhr.open("PUT",url,false);
  xhr.setRequestHeader("Authorization", "bearer" + " " + TOKEN);
  //xhr.setRequestHeader("Content-Type","application/octet-stream");
  xhr.setRequestHeader("Content-Type","application/pdf");
  xhr.setRequestHeader("Content-Encoding","base64");
  xhr.send(filecontent);
  </code></pre>
  
  <p>Is anyone able to help?</p>
  
  <p>Thank you
  Terry</p>