Possibly a bad question, I am exposing a simple ApexRest Class to accept post's from an external source.

example bellow:

global with sharing class MyOwnTypeRestResource {

global static MyUserDefinedClass echoMyType(MyUserDefinedClass ic) {
    return ic;

global class MyUserDefinedClass {

    global String string1;
    global String string2;
    global String string3;


Which accepts the input:

    <string1>value for string1</string1>
    <string2>value for string2</string2>
    <string3>value for string3</string3>

Can I change the root <request> tag to something else?

say <Submission>

  • Even if you do that, you will have an overhead of parsing XML via dom parsing Mar 7 '19 at 19:44

If you're using the parameterized version of the post body, as you are in your code, it must be formatted using request as the top-level element. This is true for both the XML- and JSON-based parsing options. If you use RestContext.request.requestBody instead, you can choose to create your own format, but you will need to use either Dom.Document or XmlStreamReader to parse the request yourself.

  • Sounds good. In the later case; I would take requestbody's blob.tostring() and then load it into the dom.doc right? Mar 7 '19 at 19:24
  • @RyanSherry Yeah
    – sfdcfox
    Mar 7 '19 at 19:31

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.