Using cURL
Perform the following steps to set up cURL and create a user for Primavera Administration using the API.
Step 1: Obtain Account Information
Contact your account administrator to obtain the account credentials required to manage users using the API. You will need:
- Username and password for Primavera Administration
- The URL of your Primavera Administration instance
Step 2: Install cURL
The examples within this topic demonstrate how to access the API using the cURL command-line tool.
To connect to the 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:
To install cURL on a Windows 64-bit system:
You are now ready to send requests to the Primavera Administration using cURL.
Step 3: Create a User
To create a user using the API, send an HTTP POST request to the /user
endpoint. Your POST request must include additional JSON data that specifies the user name, last name, first name, email, user type, and organization. This example uses a JSON file named user_example.json to specify the properties of the new user. The user_example.json file contains the following JSON data:
{"modified": [{ "loginId": "JSMITH", "organization": { "associations": [], "bidderCompany": false, "isDeletable": false, "inheritedPolicy": false, "displayName": "sfo", "id": "4", "name": "sfo" }, "statusInfo": "", "emailAddress": "jsmith@pgbu.com", "roles": [ { "displayName": "Primavera Unifier Production", "id": "77", "name": "PrimaveraUnifierProduction" } ], "locked": false, "createdBy": "COADMIN", "status": "Active", "userType": "EMP", "firstName": "Jim", "lastName": "Smith", "createdDate": "2018-01-17T15:41:26", "updatedDate": "2018-02-15T16:16:08", "pwdExpireDate": "2018-11-13T15:46:30", "pwdWarnDate": "2018-06-16T15:46:30", "provisionedDate": "2018-01-17T15:46:30", "pwdExpired": false, "pwdCantChange": false, "pwdWarned": false, "loginAttemptsCtr": "0", "changePwdAtNextLogin": true, "lastAction": "Updated", "disabled": false, "id": "205" }]}
The following example cURL command creates a user using the user_example.json file:
curl -u jsmith:mypassword1 -H "Content-Type: application/json" -H "Version:2" -X POST -d "@user_example.json" https://localhost/cloudapi/restapi/user/add-list
Note: If the user specified with the cURL -u option does not have permission to modify the specified user, or if the user does not exist, the user creation will fail, and the API will return a response of 401, 404, or 500.