When writing an example, use cURL to perform the following:
Invoke cURL using the
curl
command.Identify command components that identify locations, cookie files or write verbose output. Refer to the following table for a list of commonly used commands.
Identify the cookie file that the service will write to upon completing an operation.
Specify the HTTP communication method with the
–X
command. Note that for REST MVC, the communication method is limited to GET and PUT.Indicate that the specified content type should be declared in the HTTP request header by using the
–H
command.Identify the content type to use.
Indicate that the following text should be used within the message body of the HTTP request.
Provide the parameters and their values to be included within the message body.
Identify the REST server and port, as well as the REST call. Note that the REST call, which is indentified using the
http://<servername>…
syntax, is included in quotation marks (“ “). Technically, cURL does not require this, however any parameters that follow an ampersand (&) will not be recognized if the command is not included in quotation marks.Provide any control parameters.
REST MVC cURL Format
When invoking cURL for REST MVC examples, use the following format:
curl <command component> <cookie file> -H <content type> -d "{ <parameter> : <value>, <parameter> : <value> }" "http://<servername>:<port>/rest/model/ <REST actor-chain component>/<chain ID>?<control parameter>"
The following is a cURL example of a REST MVC external user log in. This example uses the cookie file customer_cookies.txt
, identifies the content type as JSON, and provides the parameters and their values that are used by the ProfileActor
login actor-chain.
curl -L -v -c customer_cookies.txt -H "Content-Type: application/json" -d "{ "login" : "JohnDoe@example.com" , "password" : "password123" }" "http://localhost:8080/rest/model/atg/userprofiling/ProfileActor/ login"
Legacy REST cURL Format
When invoking cURL for Legacy REST examples, use the following format:
curl <command component> <cookie file> -X <HTTP communication type> -H <content type> -d "<parameter><arg><value></arg></parameter>" "http://<servername>:<port>/rest/bean/<REST service>?<control parameter>"
The following is a cURL example of a Legacy REST external user log in. This example uses the cookie file cookies.txt
, identifies the HTTP communication method of POST and provides the MyUsername
and MyPassword
arguments.
curl -v -c cookies.txt -X POST -H "Content-Type: application/xml" \ -d "<parameters><arg1>MyUsername</arg1><arg2>MyPassword</arg2></parameters>" \ "http://myserver:8080/rest/bean/atg/userprofiling/ProfileServices/loginUser"