Chilkat Online Tools

unicodeC / Cognite API v1 / Update extraction pipelines

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkHttpResponseW resp;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttpW_Create();

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "items": [
    //     {
    //       "id": 170038996366328,
    //       "update": {
    //         "externalId": {
    //           "set": "quis commodo minim incididunt et"
    //         },
    //         "name": {
    //           "set": "sed dolor Lorem in ipsum"
    //         },
    //         "description": {
    //           "set": "cillum nostrud sed"
    //         },
    //         "dataSetId": {
    //           "set": 5808835505541566
    //         },
    //         "schedule": {
    //           "set": "@every 82504669750µs8427843087ns555708762us7123273s051539154us5900122us91861576391ns8us34751758067m770238ns227346276ns"
    //         },
    //         "rawTables": {
    //           "add": [
    //           ],
    //           "remove": [
    //           ]
    //         },
    //         "contacts": {
    //           "set": [
    //           ]
    //         },
    //         "metadata": {
    //           "set": {}
    //         },
    //         "source": {
    //           "set": "laboris ut consectetur sint"
    //         },
    //         "documentation": {
    //           "set": "ullamco"
    //         }
    //       }
    //     },
    //     {
    //       "externalId": "ad",
    //       "update": {
    //         "externalId": {
    //           "set": "do non"
    //         },
    //         "name": {
    //           "set": "esse aliquip id dolor dolore"
    //         },
    //         "description": {
    //           "set": "sed quis occaecat"
    //         },
    //         "dataSetId": {
    //           "set": 2991526305068270
    //         },
    //         "schedule": {
    //           "set": "@every 005767486h236428466h76m27880668117h795ns97s784ns"
    //         },
    //         "rawTables": {
    //           "add": [
    //           ],
    //           "remove": [
    //           ]
    //         },
    //         "contacts": {
    //           "set": [
    //           ]
    //         },
    //         "metadata": {
    //           "add": {},
    //           "remove": [
    //           ]
    //         },
    //         "source": {
    //           "set": "aliquip eu ex"
    //         },
    //         "documentation": {
    //           "set": "ut"
    //         }
    //       }
    //     }
    //   ]
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateInt(json,L"items[0].id",123);
    CkJsonObjectW_UpdateString(json,L"items[0].update.externalId.set",L"quis commodo minim incididunt et");
    CkJsonObjectW_UpdateString(json,L"items[0].update.name.set",L"sed dolor Lorem in ipsum");
    CkJsonObjectW_UpdateString(json,L"items[0].update.description.set",L"cillum nostrud sed");
    CkJsonObjectW_UpdateInt(json,L"items[0].update.dataSetId.set",123);
    CkJsonObjectW_UpdateString(json,L"items[0].update.schedule.set",L"@every 82504669750µs8427843087ns555708762us7123273s051539154us5900122us91861576391ns8us34751758067m770238ns227346276ns");
    CkJsonObjectW_UpdateNewArray(json,L"items[0].update.rawTables.add");
    CkJsonObjectW_UpdateNewArray(json,L"items[0].update.rawTables.remove");
    CkJsonObjectW_UpdateNewArray(json,L"items[0].update.contacts.set");
    CkJsonObjectW_UpdateNewObject(json,L"items[0].update.metadata.set");
    CkJsonObjectW_UpdateString(json,L"items[0].update.source.set",L"laboris ut consectetur sint");
    CkJsonObjectW_UpdateString(json,L"items[0].update.documentation.set",L"ullamco");
    CkJsonObjectW_UpdateString(json,L"items[1].externalId",L"ad");
    CkJsonObjectW_UpdateString(json,L"items[1].update.externalId.set",L"do non");
    CkJsonObjectW_UpdateString(json,L"items[1].update.name.set",L"esse aliquip id dolor dolore");
    CkJsonObjectW_UpdateString(json,L"items[1].update.description.set",L"sed quis occaecat");
    CkJsonObjectW_UpdateInt(json,L"items[1].update.dataSetId.set",123);
    CkJsonObjectW_UpdateString(json,L"items[1].update.schedule.set",L"@every 005767486h236428466h76m27880668117h795ns97s784ns");
    CkJsonObjectW_UpdateNewArray(json,L"items[1].update.rawTables.add");
    CkJsonObjectW_UpdateNewArray(json,L"items[1].update.rawTables.remove");
    CkJsonObjectW_UpdateNewArray(json,L"items[1].update.contacts.set");
    CkJsonObjectW_UpdateNewObject(json,L"items[1].update.metadata.add");
    CkJsonObjectW_UpdateNewArray(json,L"items[1].update.metadata.remove");
    CkJsonObjectW_UpdateString(json,L"items[1].update.source.set",L"aliquip eu ex");
    CkJsonObjectW_UpdateString(json,L"items[1].update.documentation.set",L"ut");

    CkHttpW_SetRequestHeader(http,L"content-type",L"application/json");
    CkHttpW_SetRequestHeader(http,L"api-key",L"{{api-key}}");

    resp = CkHttpW_PostJson3(http,L"https://domain.com/api/v1/projects/{{project}}/extpipes/update",L"application/json",json);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);

    }

Curl Command

curl -X POST
	-H "api-key: {{api-key}}"
	-H "content-type: application/json"
	-d '{
    "items": [
        {
            "id": 170038996366328,
            "update": {
                "externalId": {
                    "set": "quis commodo minim incididunt et"
                },
                "name": {
                    "set": "sed dolor Lorem in ipsum"
                },
                "description": {
                    "set": "cillum nostrud sed"
                },
                "dataSetId": {
                    "set": 5808835505541566
                },
                "schedule": {
                    "set": "@every 82504669750µs8427843087ns555708762us7123273s051539154us5900122us91861576391ns8us34751758067m770238ns227346276ns"
                },
                "rawTables": {
                    "add": [],
                    "remove": []
                },
                "contacts": {
                    "set": []
                },
                "metadata": {
                    "set": {}
                },
                "source": {
                    "set": "laboris ut consectetur sint"
                },
                "documentation": {
                    "set": "ullamco"
                }
            }
        },
        {
            "externalId": "ad",
            "update": {
                "externalId": {
                    "set": "do non"
                },
                "name": {
                    "set": "esse aliquip id dolor dolore"
                },
                "description": {
                    "set": "sed quis occaecat"
                },
                "dataSetId": {
                    "set": 2991526305068270
                },
                "schedule": {
                    "set": "@every 005767486h236428466h76m27880668117h795ns97s784ns"
                },
                "rawTables": {
                    "add": [],
                    "remove": []
                },
                "contacts": {
                    "set": []
                },
                "metadata": {
                    "add": {},
                    "remove": []
                },
                "source": {
                    "set": "aliquip eu ex"
                },
                "documentation": {
                    "set": "ut"
                }
            }
        }
    ]
}'
https://domain.com/api/v1/projects/{{project}}/extpipes/update

Postman Collection Item JSON

{
  "id": "updateExtPipes",
  "name": "Update extraction pipelines",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "extpipes",
        "update"
      ],
      "query": [
      ],
      "variable": [
      ]
    },
    "method": "POST",
    "header": [
      {
        "key": "api-key",
        "value": "{{api-key}}",
        "description": "An admin can create API keys in the Cognite console."
      },
      {
        "key": "content-type",
        "value": "application/json"
      }
    ],
    "description": "Update information for a list of extraction pipelines. Fields that are not included in the request, are not changed.",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"items\": [\n        {\n            \"id\": 170038996366328,\n            \"update\": {\n                \"externalId\": {\n                    \"set\": \"quis commodo minim incididunt et\"\n                },\n                \"name\": {\n                    \"set\": \"sed dolor Lorem in ipsum\"\n                },\n                \"description\": {\n                    \"set\": \"cillum nostrud sed\"\n                },\n                \"dataSetId\": {\n                    \"set\": 5808835505541566\n                },\n                \"schedule\": {\n                    \"set\": \"@every 82504669750µs8427843087ns555708762us7123273s051539154us5900122us91861576391ns8us34751758067m770238ns227346276ns\"\n                },\n                \"rawTables\": {\n                    \"add\": [],\n                    \"remove\": []\n                },\n                \"contacts\": {\n                    \"set\": []\n                },\n                \"metadata\": {\n                    \"set\": {}\n                },\n                \"source\": {\n                    \"set\": \"laboris ut consectetur sint\"\n                },\n                \"documentation\": {\n                    \"set\": \"ullamco\"\n                }\n            }\n        },\n        {\n            \"externalId\": \"ad\",\n            \"update\": {\n                \"externalId\": {\n                    \"set\": \"do non\"\n                },\n                \"name\": {\n                    \"set\": \"esse aliquip id dolor dolore\"\n                },\n                \"description\": {\n                    \"set\": \"sed quis occaecat\"\n                },\n                \"dataSetId\": {\n                    \"set\": 2991526305068270\n                },\n                \"schedule\": {\n                    \"set\": \"@every 005767486h236428466h76m27880668117h795ns97s784ns\"\n                },\n                \"rawTables\": {\n                    \"add\": [],\n                    \"remove\": []\n                },\n                \"contacts\": {\n                    \"set\": []\n                },\n                \"metadata\": {\n                    \"add\": {},\n                    \"remove\": []\n                },\n                \"source\": {\n                    \"set\": \"aliquip eu ex\"\n                },\n                \"documentation\": {\n                    \"set\": \"ut\"\n                }\n            }\n        }\n    ]\n}"
    }
  }
}