curl Overview

Examples within this topic demonstrate how to access the Oracle Primavera Cloud Data Service using curl.

To access the Oracle Primavera Cloud Data Service with curl:

  • Install curl, as described in Using curl.
  • Start curl and specify one or more of the command-line options described in this table.

The following table summarizes the curl options used in the examples in this document:

curl Option Description
-d <json data>

Identifies the request document, in JSON format, on the local machine. For example:

-d @mydatafile.json

-F <form data>

Identifies form data, in JSON format, on the local machine. For example:

-F @myformdatafile.json

-H <http header>:<value>

Defines one or both of the following:

  • Content-Type: Media type of the body of the request
  • Accept: Media type of the body of the request
-i Displays response header information.
-u <username>:<password>

Specifies the username and password for the Oracle Primavera Cloud account. For example:

-u jsmith:mypassword1

If your username contains a space, you will need to wrap the username text in quotes:

-u "Molly Abraham":mypassword1

-X <http verb>

Indicates the type of request. For example:

-X GET

or

-X POST

To use curl to interact with the data service, enter the curl command followed by one or more curl options and a valid endpoint.

For example:

		curl -u <username>:<password> -H "<http-header>:<value>" -X <http-verb> https://<host>:<port>/data/rest/dataservice/<endpoint>
		

The variables in the previous example should be replaced with the following information when accessing the data service:

  • <username>: The username of an application user. This user will be used to access the data service and must be assigned the application administrator privilege to access application data. For example, jsmith.
  • <password>: The password associated with the user account used to access the data service.
  • <http-header>: A valid HTTP header. For example, Content-Type.
  • <value>: A valid value for an associated HTTP header. For example, for the header Content-Type, application/json.
  • <http-verb>: A valid HTTP operation. For example, GET.
  • <host>: The name of the host on which the application is deployed. This is the URL for the Oracle Primavera Cloud application.
  • <port>: The port number assigned to the application on the application host. The port is either included in the URL or is not required.
  • <endpoint>: A valid data service endpoint, excluding the data service base URL.

Command Examples

The following examples demonstrate how to use curl to access the Oracle Primavera Cloud Data Service.

Note: Text surrounded in < > indicates a variable. You must replace variables with your own data to run the examples in this documentation. For example, replace the <username> variable with your username.

To fetch all tables that are available to use when running a query:

		curl -u <username>:<password> -X GET https://<host>:<port>/data/rest/dataservice/tables
		

The variables in the previous example should be replaced with the following information when accessing the data service:

  • <username>: The username of an application user. This user will be used to access the data service and must be assigned the application administrator privilege to access application data. For example, jsmith.
  • <password>: The password associated with the user account used to access the data service.
  • <host>: The name of the host on which the application is deployed. This is the URL for the Oracle Primavera Cloud application.
  • <port>: The port number assigned to the application on the application host. The port is either included in the URL or is not required.

Requests that use the POST method require additional data. Pass additional data to curl using the -d option. The following example sends a POST request to the /data/rest/dataservice/runquery endpoint using data stored in a JSON file named query.json.

		curl -u <username>:<password> -H "Content-Type:application/json" -X POST -d "@query.json" https://<host>:<port>/data/rest/dataservice/runquery
		

The query.json file contains the following:

"name": "My Activities",
"sinceDate": null,
"nextTableName": "Activity",
"nextKey": "1139",
"tables": [{
  "tableName": "SM_ACTIVITY",
  "columns": [
    "ACTIVITY_ID",
    "ACTIVITY_NAME",
    "ACTIVITY_TYPE",
    "STATUS",
    "START_DATE",
    "FINISH_DATE"
  ],
  "condition": {
    "columnName": null,
    "operator": "AND",
    "value1": null,
    "value2": null,
    "conditions": [{
        "columnName": "PLANNED_HOURS",
        "operator": "GREATER_THAN_OR_EQUALS",
        "value1": "1200",
        "value2": null,
        "conditions": null
      },
      {
        "columnName": "PROJ_ID",
        "operator": "EQUALS",
        "value1": "1",
        "value2": null,
        "conditions": null
      }
    ]
  }
}]