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
Farid.KognozFarid.Kognoz 

HTTP Request POST Binary data

Hi, i'm trying to POST a .doc file using the HTTPRequest Class. The file is taken from a mail attachment (blob variable). The request can send ASCII files but when it comes to binary data it doesn't work.
As for the request's body, I'm using a multipart form, the only problem I'm having is when adding the blob file to it. I tried EncodingUtil.Base64Encode and convertToHex... non of them worked.
Am I missing something here?
Any help would be apreciated;
Thanks
Farid
gv007gv007

Hello Farid,

Can you please show the code to create a multipart form for sending it in the request body. How did you create it in the controller.

 

Thanks

Gopi

aggarwalaggarwal

Hi Farid -

 

Did you get this working? Can you share with me the source code for the same. I am trying to get the same thing done - post file using HTTPRequest Class.

 

Thanks,

R Aggarwal

FaridKognozFaridKognoz

Sorry Aggarwal but I couldn't get this working. If you ever find a solution to this please share it (just curiosity at this point).

Cheers;

 

Farid

lakhanprajapati.jeclakhanprajapati.jec

Hi Guys,

I have the same use case, I need to post images to the external server using REST API.  While converting blob into string and posting the data, it gets currpted. It seems converting blob into string does not actually produce binary content instead convert into some other encoding.

 

Any help would be appriciated.

 

Thanks,

Lakhan