From salesforce I Need to expose a webservice to accept pdf/txt files from Mule and once I receive I need to store in Salesforce as an Attachment. However, from Postman while trying to hit as below I am getting the below error. So, the question is

  1. Is Mule has to convert the details in blob to me ?
  2. Is there anyway I can receive file in Salesforce directly from 3rp party system/Mule ?

Pls suggest.enter image description here

once I receive the content I can store in salesforce like below.

newAttachment.Name =AttachmentName;
newAttachment.Body=[Actual content which is in file];
newAttachment.ContentType ='Something.txt or .pdf';
newAttachment.ParentId =ca.Id;
insert newAttachment;

2 Answers 2


You could construct a payload for use with a custom Apex class, the data would have to look like:

{ "request": { "Origin": "Web", "CaseNumber": "12345", "FileBody": "<base64-encoded-data>", ... } }

But this would be inefficient for large files, and you'd have to do manual encoding/decoding. Instead, consider using the Blob resources that are already built in to Salesorce:

POST /services/data/v48.0/sobjects/Attachment HTTP/1.1
Host: my-domain.my.salesforce.com
Authorization: Bearer <token>
Content-Type: multipart/form-data; boundary="unique-boundary"
Content-Length: <calculated-length>

Content-Disposition: form-data; name="entity_attachment"
Content-Type: application/json

{ "ParentId": "<caseId>", "ContentType": "application/pdf", "Name": "filename" }

Content-Type: application/pdf
Content-Disposition: form-data; name="Body"; filename="Lic docs.pdf"



Check the documentation for all of the rules regarding this syntax.


This can be done using Postman client app. For instance, to upload a file as attachment to Salesforce, use the following:

  1. POST to the standard REST endpoint. Eg: <base_url>/services/data/v52.0/sobjects/Attachment enter image description here
  2. Under Headers, leave content-type header auto (do not set a value) enter image description here
  3. Under form-body, provide first entry (select 'text' for KEY) with json details for attachment record as value. Choose content-type=application/json. (Eg. for attachment: {"Name":"Image.jpg", "ParentId":"0012O000000TbYJQA0", "ContentType":"image/jpeg"}
  4. Under form-body, provide second entry for blob (select 'file' for KEY) and attach file under value. Choose relevant content-type. enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .