Skip to main content
added 51 characters in body
Source Link
Keith C
  • 138.3k
  • 31
  • 233
  • 476

Rather than accept say form encoded parameters it is usually more convenient (for the client and in the Apex code) to accept a JSON string that holds the parameters. For the POST case:

@HttpPost global static Result post() { String jsonString = RestContext.request.requestBody.toString(); // Use Apex JSON class to parse ... } 

For GET parameters you have to do your own string manuplationmanipulation of the URL that you can obtain from the static field RestContext.request.requestURI. (Or better use params as Jitendra illustrates.)

Rather than accept say form encoded parameters it is usually more convenient (for the client and in the Apex code) to accept a JSON string that holds the parameters. For the POST case:

@HttpPost global static Result post() { String jsonString = RestContext.request.requestBody.toString(); // Use Apex JSON class to parse ... } 

For GET parameters you have to do your own string manuplation of the URL that you can obtain from the static field RestContext.request.requestURI.

Rather than accept say form encoded parameters it is usually more convenient (for the client and in the Apex code) to accept a JSON string that holds the parameters. For the POST case:

@HttpPost global static Result post() { String jsonString = RestContext.request.requestBody.toString(); // Use Apex JSON class to parse ... } 

For GET parameters you have to do your own string manipulation of the URL that you can obtain from the static field RestContext.request.requestURI. (Or better use params as Jitendra illustrates.)

Source Link
Keith C
  • 138.3k
  • 31
  • 233
  • 476

Rather than accept say form encoded parameters it is usually more convenient (for the client and in the Apex code) to accept a JSON string that holds the parameters. For the POST case:

@HttpPost global static Result post() { String jsonString = RestContext.request.requestBody.toString(); // Use Apex JSON class to parse ... } 

For GET parameters you have to do your own string manuplation of the URL that you can obtain from the static field RestContext.request.requestURI.