Selecting a Project

Usually during a project a significant amount of data is generated. That data can be useful for post-processing, storage or analysis purposes. Congrid API exposes end-points to retrieve such data from the project.

To retrieve per project data the client application needs to know the Congrid unique projectId of the project.

To get all the projects of a company in Congrid system use the following request:

curl
JavaScript
curl -X GET -H "Content-Type: application/json" -H "Congrid-API-Token: YOUR-API-TOKEN" \
"https://api.congrid.com/v1/projects"
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.congrid.com/v1/projects',
  headers: 
   { 'congrid-api-token': 'YOUR-API-TOKEN',
     'content-type': 'application/json' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Since we only have created one project so far, an example response for the request would look like:

{
  "count": 1,
  "pageSize": 100,
  "results": [        
    {
      "id": "PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ",
      "modifiedAt": "2017-01-23T18:13:20.602Z",
      "ownerId": "ua6tvr70c14me8fjj6hf0jazj578p12h",
      "moduleIds": [
        "SAFETY_MEASUREMENTS",
        "PUNCH_LISTS"
      ],
      "name": "Tutorial project",
      "projectCode": "A-123456",
      "startedAt": "2017-01-22"
    }
   ]
 }

The response only shows one project which we added previously during the tutorial. Let's record the id PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ for further requests.

Fetching projects based on projectCode property

The optional projectCode property is commonly used to identify a project in different systems. The property in Congrid is optional and not guaranteed to be unique. However sometimes it might be more convenient to first fetch the projects based on a projectCode before accessing the data of these projects. If a unique projectCode is given to different projects, then fetching by projectCode should only return one project and the project id of this project can be used in the followup requests to fetch the project data.

curl
JavaScript
curl -X GET -H "Content-Type: application/json" -H "Congrid-API-Token: YOUR-API-TOKEN" \
 "https://api.congrid.com/v1/projects?projectCode=A-123456"
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.congrid.com/v1/projects',
  qs: { projectCode: 'A-123456' },
  headers: 
   { 'congrid-api-token': 'YOUR-API-TOKEN',
     'content-type': 'application/json' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

The response should be the same as in the previous example since there is only one project in our system and the projectCode query parameter matches the projectCode of this project.

{
  "count": 1,
  "pageSize": 100,
  "results": [
    {
      "id": "PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ",
      "modifiedAt": "2017-01-23T18:13:20.602Z",
      "ownerId": "ua6tvr70c14me8fjj6hf0jazj578p12h",
      "moduleIds": [
        "SAFETY_MEASUREMENTS",
        "PUNCH_LISTS"
      ],
      "name": "Tutorial project",
      "projectCode": "A-123456",
      "startedAt": "2017-01-22"
    }
  ]
}

results matching ""

    No results matching ""