title: How to upload pdf file to Sharepoint site using MicrosoftGraph
body: <p>I'm trying to transfer a pdf stored on a mobile device to a Sharepoint site using <a href="https://docs.microsoft.com/en-us/graph/use-the-api" rel="nofollow noreferrer">Microsoft Graph API</a>. The file is read as a base64 string and this string is set as the content of a file on the site.  </p>
  
  <p>I have been successful in transferring plain text files but unable to do so with pdfs. It seems like I’m just creating a plain text file with a .pdf extension (can change the extension to .txt and the file just contains the string version of the original file).</p>
  
  <p>Any idea on how to specify that the string being transferred is an encoded version of the file and not just plain text? I'm assuming this is the case when uploading images or any non-<code>.txt</code> files, so any related advice would be helpful.</p>
  
  <pre><code>graphClient.api('/sites/{site-id}/drives/{drive-id}/root:/UploadedFile.pdf:/content')
              .header("content-type", "application/pdf")
              .put(fileContent)
              .then((response) =&gt; {
                  console.log(response);
              });
  </code></pre>