3

I've been able to write a simple HttpPost RestResource that would accept a Base64 string as one of the parameters and make an attachment out of it.

But actually we want to use multipart instead of base64 strings. After some googling I found this blog which literally says:

REST API now supports the MIME multipart content-type standard which allows you to upload large binary files of up to 500Mb

But I also found some docs that say:

Apex REST currently doesn't support requests of Content-Type multipart/form-data.

Who should I believe? They are both on Salesforce site and both seem to be trustworthy. I've also found a lot of examples how to make an outbound multipart request, but didn't find any examples of inbound ones.

Is there a way(and an example) to write an apex HttpPost method that would accept multipart?

2
  • Just wondering, were u able to find a solution for this, I am confused too
    – manza
    Commented Aug 31, 2016 at 2:53
  • @manza no, we just went with standard API that does support multipart
    – Novarg
    Commented Aug 31, 2016 at 8:14

1 Answer 1

3

The Force.com REST API and Apex REST are not the same thing. The first is provided by the platform to interact with objects and the second is written by a developer in Apex to interact via a custom implementation.

So in short, the platform's REST API can accept a multipart binary but you cannot code your own Apex class exposed as a @RestResource and do the same thing.

From the SFDC Which API Should I Use? document:

REST API

  • What is it for? Accessing objects in your organization using REST.
  • When to use it? You want to leverage the REST architecture to integrate with your organization. No WSDL requirement. Well-suited for browser-based applications, mobile apps, and highly-interactive social applications.

APEX REST

  • What is it for? Building your own REST API in Apex. Exposes Apex classes as RESTful Web services.
  • When to use it? You need to build custom JSON responses or you want to expose custom functionality that you implemented in Apex.

You must log in to answer this question.

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