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:

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