title: What is the correct way to upload file as binary data in http post request of Whatspp business api?
body: <p>I am trying to create a capability to send invoices to our customers over whatsapp as pdf. For this I already have a invoice pdf which needs to be uploaded over whatsapp server to be sent out to our customers as per the document : <a href="https://developers.facebook.com/docs/whatsapp/api/media/" rel="nofollow noreferrer">https://developers.facebook.com/docs/whatsapp/api/media/</a></p>
  
  <p>Since it expects a binary-media data,
  I am creating a http post request body as below :</p>
  
  <pre><code>    let requestOptions = {
        method: method,
        url: "https://whatsapp-url" + '/v1/upload',
        body: Buffer.from(fs.readFileSync("path/test.pdf")),
        json: true,
        headers: {
          authorization: bearerToken,
          'content-type' : 'application/pdf'
        }
      };
  
  </code></pre>
  
  <p>As a response to this I do receive media-id from Whatsapp in the response body which I use to send message to the customer as per the document: 
  <a href="https://developers.facebook.com/docs/whatsapp/api/messages" rel="nofollow noreferrer">https://developers.facebook.com/docs/whatsapp/api/messages</a></p>
  
  <p>But alas !! the pdf file received is corrupted and does not open, Moreover I also notice that pdf sent by me is of much lessor size as compared to one I receive on the customer end over Whatsapp message.</p>
  
  <p>Can anyone help out in exactly what I might be doing wrong in creating request body for upload as I suspect there lies all my problem.</p>