I realise that I can receive parameters in the query string via the following syntax:


This also seems to work for parameters encoded in a query string format inside the message body of a POST request.

However, my use case involves a public sites page that needs to receive / parse a JSON string in the message body of the post request. This message body content is set in stone, as it's being sent from a server that's outside my control (and outside of SF) - I can only provide the URL to send it to.

Is there any way to obtain this data, or if not any other possible workaround from within SF?

  • Not clear about your question is the service is hosted at SF side? if so there is a getBody() method to extract the body from a POST request see here developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… and if you want to consume the service we have setBody() method Jul 27, 2017 at 11:54
  • @AvijitChakraborty Afraid not, the service is hosted on an external server that has nothing to do with SF.
    – berry120
    Jul 27, 2017 at 12:39
  • 3
    If you need to get a JSON that is being posted to Salesforce from another service, have you considered publishing a public REST endpoint using your site? Jul 27, 2017 at 12:47
  • @RenatoOliveira Ahah - I hadn't, but that may well be the answer here!
    – berry120
    Jul 27, 2017 at 12:57
  • 1
    An Apex REST Webservice (Apex REST Methods is probably the specific page you're looking for) is the answer to your question here. I'll let @RenatoOliveira take the answer.
    – Derek F
    Jul 27, 2017 at 13:03

1 Answer 1


Since you need to parse a JSON that is being posted by an external service, you'll probably want to build a public REST endpoint in your organisation using your public Site.

You can find more about this on the Apex Developer Guide, on sections "Exposing Apex Classes as REST Web Services" and "Apex REST Methods".

There are videos on YouTube showing how to do this as well.

  • Thanks very much, I wasn't aware of the REST endpoint functionality in Salesforce, but that fits the bill perfectly.
    – berry120
    Jul 27, 2017 at 15:25

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.