If you are using one of the client libraries that comes bundled with ATG Platform REST Web Services, you don’t need to format input. The libraries manage input for you. If you do however, use REST without the client libraries, then you will need to convert any input data to the correct format with a JSON or XML library.

The most important points to understand about the JSON or XML payload for a request are what is in the payload and how the data is identified. The request parameters are always part of the payload and if the call is a POST request/method call, then the method parameters are also passed in this format. Any request parameters are simply added to the payload as name value pairs.

Notice that in both samples which follow, the values are passed as strings, even though they are numeric. Also notice in the XML that the root tag uses parameters as the tag name.

The following sample shows JSON:

{
 "atg-rest-index": "0",
 "atg-rest-count": "10"
}

The following sample shows XML.

<parameters>
 <atg-rest-index>0</atg-rest-index>
 <atg-rest-count>10</atg-rest-count>
</parameters>

For method arguments, the name of each argument should be arg1, arg2, arg3 ... argN where N is the total number of arguments in the method call. In the following samples, arg1 and arg2 are both passed as strings, while arg3 is a repository item which is passed using a predefined format

repository path:item descriptor name:item id.

The following sample shows JSON:

{
 "atg-rest-index": "0",
 "atg-rest-count": "10"
 "arg1": "abc",
 "arg2": "55",
 "arg3": "/atg/commerce/catalog/ProductCatalog:product:prod12345"
}

The following sample shows XML.

<parameters>
 <atg-rest-index>0</atg-rest-index>
 <atg-rest-count>10</atg-rest-count>
 <arg1>abc</arg1>
 <arg2>55</arg2>
 <arg3>/atg/commerce/catalog/ProductCatalog:product:prod12345</arg3>
</parameters>
 
loading table of contents...