Im trying to set up an event driven framework, which needs a public salesforce endpoint to recieve webhook posts from a 3rd party service (mailgun).

I have put together a custom rest endpoint that works fine for simple form posts using simple key-value params, but if the webhook tries to pass its post to me I get a [{"message":"Apex REST does not support multipart/form-data requests","errorCode":"UNSUPPORTED_MEDIA_TYPE"}] and I sob uncontrollably, pounding my fist on the desk.

Has anyone successfully received multipartfom data requests into salesforce? Am wondering if rather than Rest I should do this via a a sites page and somehow scrape off the incoming info. Suggestions most appreciated!

Cheers, CH

  • 1
    which framework? – bigassforce Jan 20 '14 at 21:52
  • The mailgun service sends an event initiated post to whatever url you want. the class I have built thus far is simply an @restresource exposed via a public site. It works for non multipart posts, but multipart doesnt work. Salesforce just fires back a 415 error. – CloudHugger Jan 21 '14 at 0:01

Ok - solved this one!

For those attempting the same - I got the bulk of the answer from this great blog post http://sfdc.arrowpointe.com/2010/02/16/endpoint-for-debugging-http-callouts/

Inspired and sensing victory, I exposed a vf page via a public site and it immediately overcame the multipart format restriction. I was unsure of what i was being sent, so using the page and controller from the afore mentioned blog post (Scott Hemmeter rocks!) I changed the debugging code to pass me the form post content via a simple custom object rather than a task (as am using a public site) and then was able to visualise clearly what was being sent to me. From there was able to proceed to extracting what i needed to handle the webhook post accordingly.

Hope this helps anyone attempting the same.

cheers, CH

  • (Shameless plug!) We've got some tools for debugging API calls that might help you out without having to set up your own endpoints: blog.runscope.com/posts/… – John Sheehan Jan 22 '14 at 20:40
  • 1
    The link is broken. Do you have a valid link for that blog post? Thank you – Marcel Aug 22 '16 at 19:02

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.