Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Description: This article specifies how to use the CISPro Bulk API taking materials APIs as example.

Prerequisites:

  • This article assumes that the user is familiar with Individual Entity APIs.

  • The user have access to a service account which has access to create materials.

  • The user have access to Postman or similar software to use APIs

Step-By-Step Guide:.

Step 1 - Login to CISPro

1.1 Get Token from Foundation Hub 

A Bearer token is required to connect to Foundation Hub which will be used to get the client ID for CISPro registered with it.  

Start with doing a POST API call to /foundation/hub/api/v1/security/login API with json body of  

    "client_id":"foundation-hub", 

    "username":{{username}}, 

    "password":{{password}} 

1.2. Get Client ID from foundation hub for CISPro 

From the body of previous call, take out the bearer token and then do a GET call to /foundation/hub/api/v1/applications?$filter=name eq ‘Inventory’ with authorization using bearer token taken previously 

1.3. Get Token for CISPro from Foundation Hub 

Do a POST call to /foundation/hub/api/v1/security/login API with json body of 

    "client_id":{{Inventory_clientId}}, 

    "username":{{username}}, 

    "password":{{password}} 

Step 2 - Bulk POST API to create entities in CISPro 

POST Bulk API call can be used to create multiple same type of entities at the same time in CISPro.  

The API is /cispro/inventory/api/v1/{{entity_type}}/$bulk. 

The format for doing such call is as below 

    "operations":[ 

        { 

            "method": "POST", 

            "path": "/", 

            "data":    { 

                "molecularWeight": 134.18, 

                "formula":"C9H10O", 

                "tradename":"2-ethylbenzaldehyde", 

                "partNumber": "2", 

                "casNo":"22927-13-5", 

                "nodetypename": "Chemical", 

                "supplier_id":27835, 

                "approvedForReceiving": "Approved", 

                "physicalState": "liquid", 

                "specificGravity": 1.0, 

                "obsolete": false 

            } 

        }, 

        { 

            "method": "POST", 

            "path": "/", 

            "data":    { 

                "molecularWeight": 100.16, 

                "tradename":"2-ethylbutyraldehyde", 

                "partNumber": "2", 

                "casNo":"97-96-1", 

                "nodetypename": "Chemical", 

                "supplier_id":27835, 

                "approvedForReceiving": "Approved", 

                "physicalState": "liquid", 

                "specificGravity": 1, 

                "obsolete": false 

            } 

        } 

    ], 

    "rollBackOnError" : true 

 

Here, the Operations is an array of POST calls that would be done while using the bulk API. The rollBackOnError can be set as true or false as required. 

The Elements of Operation should have three parameter 

  • Method 

  • Path 

  • Data 

Method 

For creating entities in CISPro, the method selected should be POST and same has to written in the body under Method. Ignoring this would result in an error for that element. Providing any other method type than POST would also result in an error for that element of operations array. 

Path 

The path for creating entity in CISPro should be set to “/”. This is meant to create an entity. To create entities under a single element like receiving multiple containers for the same material, the path can be set to “/{{entity_node_id}}/receive/”. 

Data 

Data is the same data that would be sent during doing a POST to the the entity API. It should contain all the required parameters as in the normal API call to the entity. 

Outcome

The result of the POST will be 300 Multiple Choices. Individual response codes will also be returned for each operation performed. 

Step 3 - Bulk PUT API to update entities in CISPro 

This Bulk API can be used to update multiple entities at once. Same entity can also be updated once after other in the same API call. This API can only be used with the PUT method in the API call. The format of API is /inventory/api/v1/{entity}/$bulk. It requires same parameters as of the POST call. Operations is an array with individual PUT calls. The rollBackOnError can be set as true or false as required. 

The format for the call is as below 

    "operations":[ 

        { 

            "method": "PUT", 

            "path": "/90926", 

            "data":    { 

                "structure":"92039-36-6.mol\r\n  ACCLDraw09211710252D\r\n\r\n  5  4  0  0  0  0  0  0  0  0999 V2000\r\n    9.3800   -6.0679    0.0000 C   0  0  3  0  0  0  0  0  0  0  0  0\r\n   10.0831   -5.6505    0.0000 Mg  0  0  0  0  0  0  0  0  0  0  0  0\r\n    9.3800   -6.8929    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\r\n    8.6649   -5.6624    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\r\n   10.8201   -6.0799    0.0000 Cl  0  0  0  0  0  0  0  0  0  0  0  0\r\n  1  2  1  0  0  0  0\r\n  1  3  1  0  0  0  0\r\n  1  4  1  0  0  0  0\r\n  2  5  1  0  0  0  0\r\nM  END\r\n" 

            } 

        }, 

        { 

            "method": "PUT", 

            "path": "/90926", 

            "data":    { 

                "physicalState": "solid" 

 

            } 

        } 

    ], 

    "rollBackOnError" : true 

 

The Elements of Operation should have three parameter 

  • Method 

  • Path 

  • Data 

Method 

For updating entities in CISPro, the method selected should be PUT and same has to written in the body under Method. Ignoring this would result in an error for that element. Providing any other method type than PUT would also result in an error for that element of operations array. 

Path 

The path for creating entity in CISPro should be set to “/{{entity_id}}”. This is meant to update an entity. 

Data 

Data is the same data that would be sent during doing a PUT to the the entity API. The PUT operation behaves more like a PATCH operation in that it supports partial updates of an entity. On success, the updated entities are returned. 

Outcome

This endpoint will return a 300 Multiple Choices. Individual response codes will also be returned for each operation performed. See below for an example of the individual operation response codes.

Q&A:

Question - Where can more information about APIs be found?

Answer - It can be found by going to https://{{CISPro Inventory server FQDN}}/cispro/inventory/apihelp/index.

Question - Using pipeline pilot, the response is returned via Fail port. What can be done to get it from pass port?

Answer - In the http connector, under the additional response codes, add 300.

  • No labels