curl Overview
Examples within this topic demonstrate how to access the Primavera Data Service using curl.
To access the 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: |
-F <form data> |
Identifies form data, in JSON format, on the local machine. For example: |
-H <http header>:<value> |
Defines one or both of the following:
|
-i |
Displays response header information. |
-u <username>:<password> |
Specifies the username and password for the Oracle Prime Projects account. For example: If your username contains a space, you will need to wrap the username text in quotes: |
-X <http verb> |
Indicates the type of request. For example: or |
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://<url>/pds/rest-service/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.
- <url>: The URL provided to you when the application was deployed.
- <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 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://<url>/pds/rest-service/dataservice/metadata/tables?configCode=<configuration name>
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.
- <url>: The URL provided to you when the application was deployed.
- <configuration name>: The name of the configuration you want to access. .
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 /pds/rest-service/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://<url>/pds/rest-service/dataservice/runquery?configCode=<configuration name>
The query.json file contains the following:
{ "name": "My Activities", "sinceDate": null, "tables": [ { "tableName": "TASK", "columns": [ "TASK_ID", "TASK_NAME", "TASK_TYPE", "STATUS_CODE", "ACT_START_DATE", "ACT_END_DATE" ], "condition": { "operator": "AND", "conditions": [ { "columnName": "REMAIN_WORK_QTY", "operator": "GREATER_THAN_OR_EQUALS", "value1": "116", "value2": null }, { "columnName": "PROJ_ID", "operator": "EQUALS", "value1": "4603", "value2": null } ] } } ] }