0

I use standard Rest API (/services/data/v39.0/sobjects/Attachment) to upload attachment from our Support Portal and get saved in case object which works fine, but when I try to open the attachement from salesforce end I am geting file format doesn't support and its for all file formate.

Note: Our Support Portal is build using PHP.

Can someone guide me on this?

1 Answer 1

1

It could likely be a problem with encoding.

  1. Can you download the files - are they of right size?
  2. For text files: did you see the content by forcibly opening on a text editor like Notepad? If you can see the content, change the file encoding and reupload to Salesforce. Will this make the problem go away?

A simple test: Get Base64 encoded string from file, invoke REST API & check whether the file goes through.

CURL -

curl <url>/Document/ -H "Authorization: Bearer token" -H "Content-Type: multipart/form-data; boundary=\"boundary_string\"" --data-binary @att_test.json

att_test.JSON -

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

{
    "FolderId":"00l1J000001H2aIQAS", 
    "Name":"Sample File"
}

--boundary_string
Content-Type: application/jpg
Content-Disposition: form-data; name="Body"; filename="test.jpg"

<<encoded_string_here>>
2
  • Hi Prashant, Yes you are right, the file size seems be same but when I try to open a text file, I see something like this u«Z~)^þÜmm« Commented Nov 16, 2018 at 8:35
  • Edited answer to incl. simple debugging steps Commented Nov 17, 2018 at 4:01

You must log in to answer this question.

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