curl Examples
This topic includes some examples of how to send requests to the Oracle Primavera Cloud Data Service using curl commands.
Before you begin
1. curl is a third-party command-line tool used for interacting with and testing APIs, and is delivered with Windows 11 and many other operating systems.
To find which version of curl you have installed, open a command prompt and enter:
curl --version
For more information about curl, go to https://curl.se.
2. Contact your account administrator to obtain the account credentials required to manage workspaces using the Oracle Primavera Cloud Data Service.
You will need:
- A username and password for Oracle Primavera Cloud that has the application administrator privilege
- The URL of your Oracle Primavera Cloud Data Service RESTful endpoints
curl Options
The following table summarizes the curl options used in the examples:
| 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. |
-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, a valid endpoint, and any required headers.
For example:
curl -X <http-verb> https://<SERVER_URL>/data/rest/dataservice/<endpoint> -H "<http-header>:<value>" -H "Authorization: Bearer <OAuth-Access-Token>" -H "x-prime-tenant-code: <tenant-code>"
Where:
-
<http-header> is a valid HTTP header. For example,
Content-Type. -
<value> is a valid value for an associated HTTP header. For example, for the header Content-Type,
application/json. -
<http-verb> is a valid HTTP operation, such as
GETorPOST. - <SERVER_URL> is the server URL where Oracle Primavera Cloud is deployed. For example, primavera.oraclecloud.com.
-
<endpoint> is a valid data service endpoint, excluding the data service base URL. For example,
runquery.
Example: Get all tables using the
tables endpoint
This example command fetches a list of all database tables that are available to use when running a query:
curl -X GET https://<SERVER_URL>/data/rest/dataservice/tables -H "Authorization: Bearer <OAuth-Access-Token>" -H "x-prime-tenant-code: <tenant-code>"
Example: Run a query on specific database table columns using the
runquery endpoint
To run a query using the Oracle Primavera Cloud Data Service, you send an HTTP
POST request to the
/runquery endpoint.
Requests that use the
POST method require additional data. Pass additional data to curl using the
-d option.
In this example, you will query the
ACTIVITY_ID,
ACTIVITY_NAME,
ACTIVITY_TYPE,
STATUS,
START_DATE, and
FINISH_DATE columns in the
SM _ACTIVITY table, with criteria
PROJ_ID=1 and
PLANNED_HOURS >= 1200. To run the query, you will send a
POST request to the
/data/rest/dataservice/runquery endpoint using data stored in a JSON file named
query.json
:
curl -X POST -d "@query.json" https://<SERVER_URL>/data/rest/dataservice/runquery -H "Authorization: Bearer <OAuth-Access-Token>" -H "Content-Type: application/json" -H "x-prime-tenant-code: <tenant-code>"
The
query.json file used in the example above contains the following data:
{
"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
}
]
}
}]
}