When writing an example, use cURL to perform the following:

  1. Invoke cURL using the curl command.

  2. Identify command components that identify locations, cookie files or write verbose output. Refer to the cURL Command Components table for a list of commonly used commands.

  3. Identify the cookie file that the service will write to upon completing an operation.

  4. Specify the HTTP communication method with the –X command. Note that for REST MVC, the communication method is limited to GET and PUT.

  5. Indicate that the specified content type should be declared in the HTTP request header by using the –H command.

  6. Identify the content type to use. For information on content types, refer to Setting the Content-Type Value in REST Services.

  7. Indicate that the following text should be used within the message body of the HTTP request.

  8. Provide the parameters and their values to be included within the message body.

  9. 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.

  10. Provide any control parameters. Refer to Adding Control Parameters for detailed information.

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"

Copyright © 1997, 2015 Oracle and/or its affiliates. All rights reserved. Legal Notices