function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Venkatesh SVenkatesh S 

Rest API PDF Document is stored as base64 and not getting opened

Hello All,

I am using 3rd party document drive.  I am sending files from salesforce via rest api.  All the files are stored as base64 and not getting opened when it is downloaded.  What i am sending is as follows,
 
header:
'Content-Type','multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'

Body:
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="metadata"

{"indexingValues":[{"fieldName":"Doctype","values":["Test"]},{"fieldName":"DocOrigin","values":["SFDC"]}]}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="files"; filename="helloworld6.pdf"
Content-Type:application/pdf

JVBERi0xLjUNCiW1tbW1DQ**removed base64**
------WebKitFormBoundary7MA4YWxkTrZu0gW--

The document is sent to document drive USER_DEBUG [37]|DEBUG|System.HttpResponse[Status=OK, StatusCode=200]

But the document is not getting opened.  It is always showing error, when i tried to open the document in sublime, it shows the base64 code.  Please help me.

when i tried this data in postman it is working correctly, please tell me what content type are used in post man, the generate code not generating content type for files that i have uploaded.

User-added image

Thanks.
NagendraNagendra (Salesforce Developers) 
Hi Venkatesh,

Try with below-changed code:
Content-Disposition: form-data; name="Body"; filename="helloworld6.pdf"
Hope this helps.

Mark this as solved if it's resolved.

Best Regards,
Nagendra.P