How to parametize POST request on Salesforce Apex REST

On a standard POST call to a REST endpoint. The receiving endpoint expects a payload on the body of the POST. The service then parses the content of the body.

For example on the following Salesforce endpoint

I created a POST request and sent on the body the following JSON:


With Apex REST here are two ways you can create your REST POST service method

  • Create the method and supply the parameters for the function. Salesforce Apex REST will attempt to deserialize the payload data into those parameters.

Note: With this method passing the following XML payload will also work.


Consider the following when choosing which method to implement

  • If payload is easy and won’t change – method with parameters.
  • Do you have accept both JSON and XML payload – method parameters
  • For complex payload structure – method with User-defined type payload or the json String payload


Leave a Reply

Your email address will not be published. Required fields are marked *