Adding a project

Project is one of the most important entities in the Congrid system. Most of the actions performed through the system are related to a project.

To start with a simple example we will first create a new project in the system.

curl
JavaScript
curl -X POST -H "Content-Type: application/json" -H "Congrid-API-Token: YOUR-API-TOKEN" -d '{
   "name": "Tutorial project",
   "startedAt": "2017-01-22",
   "finishedAt": "2019-05-01",
   "projectCode": "A-123456",
   "statusId": "ACTIVE",
   "moduleIds" : ["PUNCH_LISTS", "SAFETY_MEASUREMENTS"]
}' "https://api.congrid.com/v1/projects"
var request = require("request");

var options = { method: 'POST',
  url: 'https://api.congrid.com/v1/projects',
  headers: 
   { 'congrid-api-token': 'YOUR-API-TOKEN',
     'content-type': 'application/json' },
  body: 
   { name: 'Tutorial project',
     startedAt: '2017-01-22',
     finishedAt: '2019-05-01',
     projectCode: 'A-123456',
     statusId: 'ACTIVE',
     moduleIds: [ 'PUNCH_LISTS', 'SAFETY_MEASUREMENTS' ] },
  json: true };

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

  console.log(body);
});

In the response you will receive an id for the project. This id uniquely identifies the project in Congrid system and you should use it in all the future requests related to this particular project.

An example response for the previous request:

{
  "id": "PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ",
  "modifiedAt": "2017-01-12T08:40:30.401Z",
  "ownerId": "ua6tvr70c14me8fjj6hf0jazj578p12h",
  "moduleIds": [
    "SAFETY_MEASUREMENTS",
    "PUNCH_LISTS"
  ],
  "name": "Tutorial project",
  "projectCode": "A-123456",
  "startedAt": "2017-01-22",
  "finishedAt": "2019-05-01",
  "statusId": "ACTIVE"
}

Let's record the id PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ for further requests.

Also note the ownerId property. This property contains the company id of the company who owns this project and is useful when we add users for the project. This is automatically set by the backend when the project is created.

Setting the project address

Setting the project address through the following end-point by replacing the {projectId} with the id from the project.

https://api.congrid.com/v1/projects/{projectId}/address

Example request:

curl
JavaScript
curl -X POST -H "Content-Type: application/json" -H "Congrid-API-Token: YOUR-API-TOKEN" -d '{
	"address1": "Kaisaniemenkatu 4 A",
	"city": "Helsinki",
	"countryCode": "FI",
	"postalCode": "00100"
}' "https://api.congrid.com/v1/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/address"
var request = require("request");

var options = { method: 'POST',
  url: 'https://api.congrid.com/v1/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/address',  
  headers: 
   { 'congrid-api-token': 'YOUR-API-TOKEN',
     'content-type': 'application/json' },
  body: 
   { address1: 'Kaisaniemenkatu 4 A',
     city: 'Helsinki',
     countryCode: 'FI',
     postalCode: '00100' },
  json: true };

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

  console.log(body);
});

Response:

{
  "address1": "Kaisaniemenkatu 4 A",
  "city": "Helsinki",
  "countryCode": "FI",
  "postalCode": "00100",
  "createdAt": "2017-02-27T10:31:57.543236Z",
  "id": "Ywdh1YJ9SQMseBZqApMe7NvcA2ZWJdYu",
  "modifiedAt": "2017-02-27T10:31:57.543287Z",
  "projectId": "PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ"
}

The rest of this chapter will discuss accessing and modifying a previously created project. If you wish to move on to filling the rest of the project base data, then you can go directly to the next chapter about adding companies to the project.

Add companies to project

Accessing a project

To access the project details of a particular project at any later time, use the previously received id.

For example to get the details of the previously added project with project id PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ lets perform a get to the projects end-point with the id set.

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

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

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

  console.log(body);
});

This should give the exactly same response as the previous project POST

{
  "id": "b1NTzZ05Zq530IUT6HPaQ9a3yYBWcL9F",
  "modifiedAt": "2017-01-23T18:13:20.602Z",
  "ownerId": "ua6tvr70c14me8fjj6hf0jazj578p12h",
  "moduleIds": [
    "SAFETY_MEASUREMENTS",
    "PUNCH_LISTS"
  ],
  "name": "Tutorial project",
  "projectCode": "A-123456",
  "startedAt": "2017-01-22",
  "finishedAt": "2019-05-01",
  "statusId": "ACTIVE"
}

results matching ""

    No results matching ""