Chilkat Online Tools

C / EDS API / Dokumentu saraksts.

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonArray.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkJsonObject queryParams;
    HCkHttpResponse resp;
    HCkStringBuilder sbResponseBody;
    HCkJsonArray jarrResp;
    int respStatusCode;
    HCkJsonObject json;
    int Id;
    const char *Izveidots;
    const char *Iesniegts;
    const char *DokumentaVersija;
    const char *DokumentaVeids;
    const char *PeriodsNo;
    const char *PeriodsLidz;
    const char *Papildinformacija;
    int StatussId;
    const char *Statuss;
    BOOL IrBridinajumi;
    BOOL VarIesniegt;
    BOOL VarDzest;
    BOOL IrSanemtasAtbildes;
    BOOL Arhivets;
    int i;
    int count_i;

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

    http = CkHttp_Create();

    queryParams = CkJsonObject_Create();
    CkJsonObject_UpdateInt(queryParams,"id",25210683);
    CkJsonObject_UpdateString(queryParams,"dokumentaVeidsKods","nisi cillum sed");
    CkJsonObject_UpdateInt(queryParams,"statussId",25210683);
    CkJsonObject_UpdateString(queryParams,"izveidotsNo","nisi cillum sed");
    CkJsonObject_UpdateString(queryParams,"izveidotsLidz","nisi cillum sed");
    CkJsonObject_UpdateString(queryParams,"iesniegtsNo","nisi cillum sed");
    CkJsonObject_UpdateString(queryParams,"iesniegtsLidz","nisi cillum sed");
    CkJsonObject_UpdateString(queryParams,"periodsNo","nisi cillum sed");
    CkJsonObject_UpdateString(queryParams,"periodsLidz","nisi cillum sed");
    CkJsonObject_UpdateInt(queryParams,"izlaistIerakstus",25210683);
    CkJsonObject_UpdateInt(queryParams,"atgrieztIerakstus",25210683);

    CkHttp_SetRequestHeader(http,"Accept","application/json");

    resp = CkHttp_QuickRequestParams(http,"GET","https://eds.vid.gov.lv/api/doc",queryParams);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkJsonObject_Dispose(queryParams);
        return;
    }

    sbResponseBody = CkStringBuilder_Create();
    CkHttpResponse_GetBodySb(resp,sbResponseBody);

    jarrResp = CkJsonArray_Create();
    CkJsonArray_LoadSb(jarrResp,sbResponseBody);
    CkJsonArray_putEmitCompact(jarrResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonArray_emit(jarrResp));

    respStatusCode = CkHttpResponse_getStatusCode(resp);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttpResponse_header(resp));
        printf("Failed.\n");
        CkHttpResponse_Dispose(resp);
        CkHttp_Dispose(http);
        CkJsonObject_Dispose(queryParams);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonArray_Dispose(jarrResp);
        return;
    }

    CkHttpResponse_Dispose(resp);

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // [
    //   {
    //     "Id": 63381534,
    //     "Izveidots": "2000-01-31T00:00:00",
    //     "Iesniegts": "2000-01-31T00:00:00",
    //     "DokumentaVersija": "ut aute enim et pariatur",
    //     "DokumentaVeids": "commodo",
    //     "PeriodsNo": "2000-01-31T00:00:00",
    //     "PeriodsLidz": "2000-01-31T00:00:00",
    //     "Papildinformacija": "in mollit Ut",
    //     "StatussId": -47605421,
    //     "Statuss": "Lorem",
    //     "IrBridinajumi": true,
    //     "VarIesniegt": true,
    //     "VarDzest": false,
    //     "IrSanemtasAtbildes": false,
    //     "Arhivets": false
    //   },
    //   {
    //     "Id": 48168202,
    //     "Izveidots": "2000-01-31T00:00:00",
    //     "Iesniegts": "2000-01-31T00:00:00",
    //     "DokumentaVersija": "est dolor in non dolore",
    //     "DokumentaVeids": "minim amet",
    //     "PeriodsNo": "2000-01-31T00:00:00",
    //     "PeriodsLidz": "2000-01-31T00:00:00",
    //     "Papildinformacija": "cillum mollit occaecat eiusmod",
    //     "StatussId": -94109410,
    //     "Statuss": "laborum incididunt consectetur",
    //     "IrBridinajumi": false,
    //     "VarIesniegt": false,
    //     "VarDzest": false,
    //     "IrSanemtasAtbildes": false,
    //     "Arhivets": true
    //   }
    // ]

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    i = 0;
    count_i = CkJsonArray_getSize(jarrResp);
    while (i < count_i) {
        json = CkJsonArray_ObjectAt(jarrResp,i);
        Id = CkJsonObject_IntOf(json,"Id");
        Izveidots = CkJsonObject_stringOf(json,"Izveidots");
        Iesniegts = CkJsonObject_stringOf(json,"Iesniegts");
        DokumentaVersija = CkJsonObject_stringOf(json,"DokumentaVersija");
        DokumentaVeids = CkJsonObject_stringOf(json,"DokumentaVeids");
        PeriodsNo = CkJsonObject_stringOf(json,"PeriodsNo");
        PeriodsLidz = CkJsonObject_stringOf(json,"PeriodsLidz");
        Papildinformacija = CkJsonObject_stringOf(json,"Papildinformacija");
        StatussId = CkJsonObject_IntOf(json,"StatussId");
        Statuss = CkJsonObject_stringOf(json,"Statuss");
        IrBridinajumi = CkJsonObject_BoolOf(json,"IrBridinajumi");
        VarIesniegt = CkJsonObject_BoolOf(json,"VarIesniegt");
        VarDzest = CkJsonObject_BoolOf(json,"VarDzest");
        IrSanemtasAtbildes = CkJsonObject_BoolOf(json,"IrSanemtasAtbildes");
        Arhivets = CkJsonObject_BoolOf(json,"Arhivets");
        CkJsonObject_Dispose(json);
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkJsonObject_Dispose(queryParams);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonArray_Dispose(jarrResp);

    }

Curl Command

curl -G -d "id=25210683"
	-d "dokumentaVeidsKods=nisi%20cillum%20sed"
	-d "statussId=25210683"
	-d "izveidotsNo=nisi%20cillum%20sed"
	-d "izveidotsLidz=nisi%20cillum%20sed"
	-d "iesniegtsNo=nisi%20cillum%20sed"
	-d "iesniegtsLidz=nisi%20cillum%20sed"
	-d "periodsNo=nisi%20cillum%20sed"
	-d "periodsLidz=nisi%20cillum%20sed"
	-d "izlaistIerakstus=25210683"
	-d "atgrieztIerakstus=25210683"
	-H "Accept: application/json"
https://eds.vid.gov.lv/api/doc

Postman Collection Item JSON

{
  "name": "Dokumentu saraksts.",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "doc"
      ],
      "query": [
        {
          "key": "id",
          "value": "25210683",
          "description": "Dokumenta numurs."
        },
        {
          "key": "dokumentaVeidsKods",
          "value": "nisi cillum sed",
          "description": "Dokumenta veida kods."
        },
        {
          "key": "statussId",
          "value": "25210683",
          "description": "Dokumenta statusa id."
        },
        {
          "key": "izveidotsNo",
          "value": "nisi cillum sed",
          "description": "Dokumenta izveidošanas datums (no)."
        },
        {
          "key": "izveidotsLidz",
          "value": "nisi cillum sed",
          "description": "Dokumenta izveidošanas datums (līdz)."
        },
        {
          "key": "iesniegtsNo",
          "value": "nisi cillum sed",
          "description": "Dokumenta iesniegšanas datums (no)."
        },
        {
          "key": "iesniegtsLidz",
          "value": "nisi cillum sed",
          "description": "Dokumenta iesniegšanas datums (līdz)."
        },
        {
          "key": "periodsNo",
          "value": "nisi cillum sed",
          "description": "Dokumenta perioda sākums."
        },
        {
          "key": "periodsLidz",
          "value": "nisi cillum sed",
          "description": "Dokumenta perioda beigas."
        },
        {
          "key": "izlaistIerakstus",
          "value": "25210683",
          "description": "No rezultāta izlaižamo ierakstu skaits."
        },
        {
          "key": "atgrieztIerakstus",
          "value": "25210683",
          "description": "Atgriežamo ierakstu skaits (max 100)."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc"
          ],
          "query": [
            {
              "key": "id",
              "value": "25210683"
            },
            {
              "key": "dokumentaVeidsKods",
              "value": "nisi cillum sed"
            },
            {
              "key": "statussId",
              "value": "25210683"
            },
            {
              "key": "izveidotsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "izveidotsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniegtsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniegtsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "izlaistIerakstus",
              "value": "25210683"
            },
            {
              "key": "atgrieztIerakstus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "[\n  {\n    \"Id\": 63381534,\n    \"Izveidots\": \"2000-01-31T00:00:00\",\n    \"Iesniegts\": \"2000-01-31T00:00:00\",\n    \"DokumentaVersija\": \"ut aute enim et pariatur\",\n    \"DokumentaVeids\": \"commodo\",\n    \"PeriodsNo\": \"2000-01-31T00:00:00\",\n    \"PeriodsLidz\": \"2000-01-31T00:00:00\",\n    \"Papildinformacija\": \"in mollit Ut\",\n    \"StatussId\": -47605421,\n    \"Statuss\": \"Lorem\",\n    \"IrBridinajumi\": true,\n    \"VarIesniegt\": true,\n    \"VarDzest\": false,\n    \"IrSanemtasAtbildes\": false,\n    \"Arhivets\": false\n  },\n  {\n    \"Id\": 48168202,\n    \"Izveidots\": \"2000-01-31T00:00:00\",\n    \"Iesniegts\": \"2000-01-31T00:00:00\",\n    \"DokumentaVersija\": \"est dolor in non dolore\",\n    \"DokumentaVeids\": \"minim amet\",\n    \"PeriodsNo\": \"2000-01-31T00:00:00\",\n    \"PeriodsLidz\": \"2000-01-31T00:00:00\",\n    \"Papildinformacija\": \"cillum mollit occaecat eiusmod\",\n    \"StatussId\": -94109410,\n    \"Statuss\": \"laborum incididunt consectetur\",\n    \"IrBridinajumi\": false,\n    \"VarIesniegt\": false,\n    \"VarDzest\": false,\n    \"IrSanemtasAtbildes\": false,\n    \"Arhivets\": true\n  }\n]"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc"
          ],
          "query": [
            {
              "key": "id",
              "value": "25210683"
            },
            {
              "key": "dokumentaVeidsKods",
              "value": "nisi cillum sed"
            },
            {
              "key": "statussId",
              "value": "25210683"
            },
            {
              "key": "izveidotsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "izveidotsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniegtsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniegtsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "izlaistIerakstus",
              "value": "25210683"
            },
            {
              "key": "atgrieztIerakstus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Lietotājam nav tiesību veikt šo darbību.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc"
          ],
          "query": [
            {
              "key": "id",
              "value": "25210683"
            },
            {
              "key": "dokumentaVeidsKods",
              "value": "nisi cillum sed"
            },
            {
              "key": "statussId",
              "value": "25210683"
            },
            {
              "key": "izveidotsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "izveidotsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniegtsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniegtsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "izlaistIerakstus",
              "value": "25210683"
            },
            {
              "key": "atgrieztIerakstus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Pārsniegts izsaukumu skaita ierobežojums.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc"
          ],
          "query": [
            {
              "key": "id",
              "value": "25210683"
            },
            {
              "key": "dokumentaVeidsKods",
              "value": "nisi cillum sed"
            },
            {
              "key": "statussId",
              "value": "25210683"
            },
            {
              "key": "izveidotsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "izveidotsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniegtsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniegtsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "izlaistIerakstus",
              "value": "25210683"
            },
            {
              "key": "atgrieztIerakstus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}