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?

0

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>>
  • 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« – Manojkumar Muthu Nov 16 '18 at 8:35
  • Edited answer to incl. simple debugging steps – Prashanth K Nov 17 '18 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.