Using curl

Perform the following steps to set up curl and create a project for Oracle Primavera Cloud using the Oracle Primavera Cloud API.

Step 1: Obtain Account Information

Contact your account administrator to obtain the account credentials required to manage workspaces using the API. You will need:

  • A username and password for Oracle Primavera Cloud
  • The URL of your Oracle Primavera Cloud instance

Step 2: Install curl

The examples within this topic demonstrate how to access the Oracle Primavera Cloud API using the curl command-line tool.

To connect to the Oracle Primavera Cloud API, you must install a version of curl that supports SSL. When you connect to the API, you must provide an SSL certificate authority (CA) certificate file or bundle to authenticate against the Verisign CA certificate. See also: curl Overview

To install curl on a Windows 64-bit system:

  1. In your browser, navigate to the curl home page and select Download.
  2. On the curl Releases and Downloads page, locate the SSL-enabled version of the curl software for your operating system, click the link to download the ZIP file, and install the software.
  3. Navigate to the curl CA Certs page at http://curl.haxx.se/docs/caextract.html and download the cacert.pem SSL CA certificate bundle in the folder where you installed curl.
  4. Open the command-line, navigate to the directory where you installed curl, and set the curl environment variable, CURL_CA_BUNDLE, to the location of an SSL certificate authority (CA) certificate bundle. For example:
    C:\curl> set CURL_CA_BUNDLE=cacert.pem
    
    

You are now ready to send requests to the Oracle Primavera Cloud API using curl.

Step 3: Create a Project

To create a project using the Primavera Cloud API, send an HTTP POST request to the /project endpoint. Your POST request must include additional JSON data that specifies the project name, parent workspace, and project code. This example uses a JSON file named harbour_example.json to specify the fields of the new project. The harbour_example.json file contains the following JSON data:

{
  "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"
}
 

The following example curl command creates a project under the parent workspace using the harbour_example.json file:

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.

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>"

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.

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, 404, or 500.