You can include control and functional parameters in the HTTP message body of an ATG REST Web Services request. The following HTTP request includes two functional parameters and a control parameter in its message body. The content in the message body is specified by the -d
flag in this cURL command.
curl -L -v -b customer_cookies.txt -H "Content-Type: application/json" -d "{ "login" : "JohnDoe@example.com" , "password" : "password123" }" "http://localhost:8280/rest/model/atg/userprofiling/ProfileActor/ login?atg-rest-user-input=MyMessageId"
The ATG REST Web Services server can interpret message body parameters in one of the following three markup formats. Make sure you set the correct Content-Type
value for the markup that you use.
XML
JSON
URL query string in Legacy REST
Note: The Legacy REST Web Services server will only accept parameters in the message body of a POST or PUT HTTP request. If you need to use the GET or DELETE methods, you need to include data with your request, and you cannot include URL parameters, use the
atg-rest-view
andatg-rest-http-method
control parameters. See Handling POST Requests as Other Methods.
Setting the Content-Type Value in ATG REST Services
Set the Content-Type
value when you send an HTTP message with parameters in its message body. The ATG REST Web Services server uses this value to determine how to interpret the parameters. If you do not include the Content-Type
or include a value that does not match the markup of your parameters, the server will ignore the message body.
Use one of the following Content-Type
values to specify the markup of the parameters in a message body.
Content-Type: application/xml
Content-Type: application/json
Content-Type: application/x-www-form-urlencoded
The following example shows an HTTP request that sets its Content-Type
to application/xml
.
curl -v -c cookies.txt -X POST \ -H "Content-Type: application/xml" \ -d "<parameters><arg1>MyUsername</arg1><arg2>MyPassword</arg2><atg-rest-user-input>MyMessageId</atg-rest-user-input></parameters>" http://servername:8080/rest/ bean/atg/userprofiling/ProfileServices/loginUser * About to connect() to servername port 8080 (#0) * Trying 12.34.567.890... connected * Connected to servername (12.34.567.890) port 8080 (#0) > POST /rest/bean/atg/userprofiling/ProfileServices/loginUser HTTP/1.1 > User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 > Host: servername:8080 > Accept: */* > Content-Type: application/xml > Content-Length: 125
XML Parameter Markup in ATG REST Services
You can use eXtensible Markup Language (XML) to format parameters in the message body of an ATG REST Web Services request.
Enclose all message body content in a parameters
element as shown in the example below. Include each parameter in a separate child element. Use the name of the parameter as its element name.
<parameters> <login>Username</login> <password>Password</password> <atg-rest-user-input>MyMessageId</atg-rest-user-input> </parameters>
Make sure that you specify Content-Type: application/xml
in the HTTP message.
JSON Parameter Markup in ATG REST Services
You can use JavaScript Object Notation (JSON) to format parameters in the message body of a Legacy REST Web Services request.
Enclose the parameters in standard JSON format as shown in the example below. Include each parameter in a separate name and value pair. Use the name of the parameter as the name for the pair. For positional parameters that do not have names, use the arg1, arg2, arg3 convention as the names for the pairs.
{ "login": "Username", "password": "Password", "atg-rest-user-input": "MyMessageId" }
Make sure that you specify Content-Type: application/json
in the HTTP message.
URL Query String Parameter Markup
You can use the URL query string format to include parameters in the message body of a Legacy REST Web Services request.
Include the parameters in standard URL query string format as shown in the example below. Include each parameter in a separate name and value pair. Use the name of the parameter as the name for the pair. For positional parameters that do not have names, use the arg1, arg2, arg3 convention as the names for the pairs.
arg1=MyUsername&arg2=MyPassword&atg-rest-user-input=MyMessageId
URL encode any special URL characters in the parameter values. Make sure that you specify Content-Type: application/x-www-form-urlencoded
in the HTTP message.