curl Overview
Examples within this document demonstrate how to access the Oracle Prime Projects REST API using curl.
To access the Oracle Prime Projects 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: |
-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: |
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 -u <username>:<password> -H "<http-header>:<value>" -H "Version:<api-version>" -X <http-verb> https://<host>:<port>/primeapi/restapi/<endpoint>
The variables in the previous example should be replaced with the following information when accessing the API:
- <username>: The username of an application user. This user will be used to access the API and must have permission to access requested application data. For example, jsmith.
- <password>: The password associated with the user account used to access the API.
- <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. For example, localhost.
- <port>: The port number assigned to the application on the application host. For example, 7001.
- <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 Prime Projects 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 <username> variable with your username.
To fetch a project object by its project ID:
curl -u <username>:<password> -H "Accept:application/json" -X GET https://<host>:<port>/primeapi/restapi/project/5706
The variables in the previous example should be replaced with the following information when accessing the API:
- <username>: The username of an application user. This user will be used to access the API and must have permission to access requested application data. For example, jsmith.
- <password>: The password associated with the user account used to access the API.
- <host>: The name of the host on which the application is deployed. For example, localhost.
- <port>: The port number assigned to the application on the application host. For example, 7001.
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" }
To create a project using this JSON data:
curl -u <username>:<password> -H "Content-Type: application/json" -X POST -d "@harbour_example.json" https://<host>:<port>/primeapi/restapi/project
The variables in the previous example should be replaced with the following information when accessing the API:
- <username>: The username of an application user. This user will be used to access the API and must have permission to access requested application data. For example, jsmith.
- <password>: The password associated with the user account used to access the API.
- <host>: The name of the host on which the application is deployed. For example, localhost.
- <port>: The port number assigned to the application on the application host. For example, 7001.
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.