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
Leafen SandyLeafen Sandy 

Does apex support rest api for multipart/form-data requests made from external system

If there is a possiblity, then

Can I get a code sample (having @http post method) on how to upload pdf file into salesforce object (say as an attachment) sent to salesforce with a http request using multipart/from-data from some external site.

For a while I've gone through multipart/form-data in the developer forum, but I could only find the HTTP Request samples made from salesforce and not to salesforce.

Thanks,
Leafen.
Raj VakatiRaj Vakati
Yes .. It Suports 

Refer this link 

https://salesforce.stackexchange.com/questions/132135/how-can-i-compose-a-multipart-form-data-request
https://developer.salesforce.com/forums/?id=9060G000000BiXuQAK
Leafen SandyLeafen Sandy
Hi Raj,

Thanks for your reply.

I've gone through both of these links(even already) and I guess there they are just making a http request from salesforce to a external location.

But I actually want to write a  RESTful Web service Apex class (@RestResource(urlMapping='/url/')) to receive the request sent from an external system.

I've written it many times before but not sure what kind of change should I do to handle a request having multipart/form-data as a content type in its header.

https://salesforce.stackexchange.com/questions/176856/help-with-rest-api-on-multipart-content-type

User-added image


Even in the above link, one of the answer is like its not supported.

So just want to know, is it still not supported or is there an update on that.

Thanks.
Alok Singh 140Alok Singh 140
https://salesforcetrail.blogspot.com/2020/01/upload-document-using-rest-api-from.html 
Follow This blog.
Fabian Manzano 6Fabian Manzano 6
From my knowledge it does not support, if you have control in the inbound call, what I do is encode this way when i receive the API I decode it:
Attachment a = new Attachment();
a.Name = 'xxxx';
a.Body = EncodingUtil.base64Decode('xxx');
a.ParentId = 'xxxx';
....

 
Muralidhar S (Salesforce)Muralidhar S (Salesforce)

Here is a solution using which we can create a custom Apex REST service to accept multipart/form-data requests

https://inteygrate.com/apex-rest-does-not-support-multipart-form-data-requests/