On this particular page: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_methods.htm

About halfway down, you'll see a method which I have included in my class

global class MyClassPostStudy{

    global static void myPostMethod(String s1, Integer i1, Boolean b1, String s2){
        system.debug('this hit');

By going to Workbench and using the REST Explorer - I'm able to parse the JSON in the example just fine.

  "s1" : "my first string",
  "i1" : 123,
  "s2" : "my second string",
  "b1" : false

However I'm getting an error when I parse the XML example:

  <s1>my first string</s1>
  <s2>my second string</s2>

message: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [line:1, column:2] errorCode: JSON_PARSER_ERROR

Error Screenshot

1 Answer 1


I figured it out - I needed to go into the 'Headers' button in Workbench and change the

Content-Type: application/JSON; charset=UTF-8 
Accept: application/JSON


Content-Type: application/xml; charset=UTF-8
Accept: application/xml

enter image description here

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.