curl Overview

Examples within this document demonstrate how to access the Oracle Primavera Cloud REST API using curl.

To access the Oracle Primavera Cloud REST API 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.
-X <http-verb>

Indicates the type of request. For example:

-X DELETE

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

For example:

curl -X <http-verb> https://<SERVER_URL>/api/restapi/<endpoint> -H "Authorization: Bearer <OAuth-Access-Token>" -H "Content-Type: application/json" -H "Version: <versionNumber>" -H "x-prime-tenant-code: <tenant-code>"

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

Element Description
<SERVER_URL> The server URL where the application is deployed. For example, primavera.oraclecloud.com.
<OAuth-Access-Token> The OAuth token generated using Basic Authentication or an authorization server.
<versionNumber> The API version. Providing this is optional; the default is the latest version which is 3.
<tenant-code> The Primavera Cloud tenant where the data exists.
<http-verb> The REST API method of the API. Example: GET, POST, PUT, DELETE.

Command Examples

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

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 <versionNumber> variable with 3.

To fetch a project object by its project ID

curl -X GET https://<SERVER_URL>/api/restapi/project/5706 -H "Authorization: Bearer <OAuth-Access-Token>" -H "Content-Type: application/json" -H "Version: <versionNumber>" -H "x-prime-tenant-code: <tenant-code>"

To create a project using this JSON data

API 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 /project endpoint using data stored in a JSON file named harbour_example.json. The harbour_example.json file contains the following:

{
  "projectCode": "EC00610",
  "projectName": "Harbour Pointe Assisted Living Center",
  "workspaceId": 1,
  "planStartDate": "2017-09-01T07:00:00.-0700",
  "status": "ACTIVE",
  "description": "The assisted living center project is a long term project scheduled for completion in 2021 and is a joint venture with ABC Corp.",
  "scheduledFinishDate": "2021-08-31T00:00:00.-0700"
}

curl -X POST -d "@harbour_example.json" https://<SERVER_URL>/api/restapi/project -H "Authorization: Bearer <OAuth-Access-Token>" -H "Content-Type: application/json" -H "Version: <versionNumber>" -H "x-prime-tenant-code: <tenant-code>"

Note: If the user specified with the curl -u option does not have permission to modify the specified parent workspace, or if the parent workspace does not exist, the project creation will fail, and the API will return a response of 401 or 404.