Chilkat Online Tools

unicodeC / EDS API / Dokuments "IeIeN pārskats par izmaksām nerezidentiem".

Back to Collection Items

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

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *Vards;
    const wchar_t *Uzvards;
    const wchar_t *Valsts;
    const wchar_t *AdrIela;
    const wchar_t *AdrPilseta;
    const wchar_t *AdrPasts;
    const wchar_t *IenVeids;
    int IzmDatums;
    const wchar_t *IenSumma;
    const wchar_t *NodLikme;
    const wchar_t *NodSumma;
    const wchar_t *CitsPersKods;
    const wchar_t *LrNmrKods;
    const wchar_t *DzimDatums;
    const wchar_t *ATVK;
    const wchar_t *JpKods;
    const wchar_t *JpNosaukums;
    const wchar_t *Piezimes;
    int ParskGads;
    const wchar_t *Epasts;
    const wchar_t *Talrunis;
    const wchar_t *ParskMen;
    const wchar_t *Sagatavotajs;
    const wchar_t *NmrKods;
    int Id;
    const wchar_t *UID;
    BOOL Precizejums;
    int PrecizejamaisDokuments;
    const wchar_t *PrecizejumaPamatojums;
    int i;
    int count_i;

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

    http = CkHttpW_Create();

    CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkHttpW_QuickGetSb(http,L"https://eds.vid.gov.lv/api/doc/inrv2/:id",sbResponseBody);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jResp,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jResp,FALSE);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",CkJsonObjectW_emit(jResp));

    respStatusCode = CkHttpW_getLastStatus(http);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpW_lastHeader(http));
        wprintf(L"Failed.\n");
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

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

    // {
    //   "ParskGads": 54743069,
    //   "Epasts": "magna ad nostrud occaecat",
    //   "Talrunis": "laboris mollit",
    //   "ParskMen": "commodo deserunt",
    //   "Sagatavotajs": "dolore nulla",
    //   "NmrKods": "nostrud su",
    //   "TabulaFP": [
    //     {
    //       "Vards": "in",
    //       "Uzvards": "sunt in",
    //       "Valsts": "in laborum in ullamco",
    //       "AdrIela": "officia",
    //       "AdrPilseta": "officia aute ad magna do",
    //       "AdrPasts": "elit dolor",
    //       "IenVeids": "velit adipisicing in Excepteur",
    //       "IzmDatums": 17,
    //       "IenSumma": -5811443.522479072,
    //       "NodLikme": 23853015.107451633,
    //       "NodSumma": -35352699.91027565,
    //       "CitsPersKods": "Excepteur fugiat",
    //       "LrNmrKods": "e",
    //       "DzimDatums": "2000-01-31T00:00:00",
    //       "ATVK": "enim non ipsum"
    //     },
    //     {
    //       "Vards": "voluptate cillum laborum",
    //       "Uzvards": "ut velit aliquip occaecat nulla",
    //       "Valsts": "officia reprehenderit sint",
    //       "AdrIela": "dese",
    //       "AdrPilseta": "eu sunt",
    //       "AdrPasts": "et",
    //       "IenVeids": "fugiat eu",
    //       "IzmDatums": 16,
    //       "IenSumma": -3921734.7059562653,
    //       "NodLikme": 23938705.79623814,
    //       "NodSumma": -17258687.90274711,
    //       "CitsPersKods": "sunt minim",
    //       "LrNmrKods": "eu",
    //       "DzimDatums": "2000-01-31T00:00:00",
    //       "ATVK": "ea nisi irure"
    //     }
    //   ],
    //   "TabulaJP": [
    //     {
    //       "Valsts": "ipsum eu id ea",
    //       "AdrIela": "nisi mollit irure Excepteur",
    //       "AdrPilseta": "cillum laborum",
    //       "AdrPasts": "dolor cupidata",
    //       "IenVeids": "fugiat ex consequat",
    //       "IzmDatums": 29,
    //       "IenSumma": 35501102.52214521,
    //       "NodLikme": -40720481.84149244,
    //       "NodSumma": 73375233.76676768,
    //       "JpKods": "mollit est Lorem aute",
    //       "JpNosaukums": "fugiat consequa",
    //       "Piezimes": "veniam in",
    //       "ATVK": "veniam reprehenderit esse adipisicing"
    //     },
    //     {
    //       "Valsts": "Excepteur deserunt",
    //       "AdrIela": "adipisicing labore commodo cillum in",
    //       "AdrPilseta": "labore non nostrud magna",
    //       "AdrPasts": "ut fugiat occaecat ",
    //       "IenVeids": "nisi ex commodo",
    //       "IzmDatums": 24,
    //       "IenSumma": -49006663.90657453,
    //       "NodLikme": 32085369.934580848,
    //       "NodSumma": -55044059.760223664,
    //       "JpKods": "culpa voluptate dolor Duis sed",
    //       "JpNosaukums": "fugiat quis occaecat qui",
    //       "Piezimes": "culpa velit elit",
    //       "ATVK": "Lorem voluptate aliqua ut"
    //     }
    //   ],
    //   "Id": 9851816,
    //   "UID": "officia incididunt quis",
    //   "Precizejums": false,
    //   "PrecizejamaisDokuments": -23042510,
    //   "PrecizejumaPamatojums": "nostrud dolor"
    // }

    // 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.

    ParskGads = CkJsonObjectW_IntOf(jResp,L"ParskGads");
    Epasts = CkJsonObjectW_stringOf(jResp,L"Epasts");
    Talrunis = CkJsonObjectW_stringOf(jResp,L"Talrunis");
    ParskMen = CkJsonObjectW_stringOf(jResp,L"ParskMen");
    Sagatavotajs = CkJsonObjectW_stringOf(jResp,L"Sagatavotajs");
    NmrKods = CkJsonObjectW_stringOf(jResp,L"NmrKods");
    Id = CkJsonObjectW_IntOf(jResp,L"Id");
    UID = CkJsonObjectW_stringOf(jResp,L"UID");
    Precizejums = CkJsonObjectW_BoolOf(jResp,L"Precizejums");
    PrecizejamaisDokuments = CkJsonObjectW_IntOf(jResp,L"PrecizejamaisDokuments");
    PrecizejumaPamatojums = CkJsonObjectW_stringOf(jResp,L"PrecizejumaPamatojums");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"TabulaFP");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        Vards = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].Vards");
        Uzvards = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].Uzvards");
        Valsts = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].Valsts");
        AdrIela = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].AdrIela");
        AdrPilseta = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].AdrPilseta");
        AdrPasts = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].AdrPasts");
        IenVeids = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].IenVeids");
        IzmDatums = CkJsonObjectW_IntOf(jResp,L"TabulaFP[i].IzmDatums");
        IenSumma = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].IenSumma");
        NodLikme = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].NodLikme");
        NodSumma = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].NodSumma");
        CitsPersKods = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].CitsPersKods");
        LrNmrKods = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].LrNmrKods");
        DzimDatums = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].DzimDatums");
        ATVK = CkJsonObjectW_stringOf(jResp,L"TabulaFP[i].ATVK");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"TabulaJP");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        Valsts = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].Valsts");
        AdrIela = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].AdrIela");
        AdrPilseta = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].AdrPilseta");
        AdrPasts = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].AdrPasts");
        IenVeids = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].IenVeids");
        IzmDatums = CkJsonObjectW_IntOf(jResp,L"TabulaJP[i].IzmDatums");
        IenSumma = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].IenSumma");
        NodLikme = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].NodLikme");
        NodSumma = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].NodSumma");
        JpKods = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].JpKods");
        JpNosaukums = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].JpNosaukums");
        Piezimes = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].Piezimes");
        ATVK = CkJsonObjectW_stringOf(jResp,L"TabulaJP[i].ATVK");
        i = i + 1;
    }



    CkHttpW_Dispose(http);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jResp);

    }

Curl Command

curl -X GET
	-H "Accept: application/json"
https://eds.vid.gov.lv/api/doc/inrv2/:id

Postman Collection Item JSON

{
  "name": "Dokuments \"IeIeN pārskats par izmaksām nerezidentiem\".",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/doc/inrv2/:id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "doc",
        "inrv2",
        ":id"
      ],
      "variable": [
        {
          "key": "id",
          "value": "25210683",
          "description": "(Required) Dokumenta id."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc/inrv2/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "inrv2",
            ":id"
          ],
          "variable": [
            {
              "key": "id",
              "value": "25210683",
              "description": "(Required) Dokumenta id."
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"ParskGads\": 54743069,\n  \"Epasts\": \"magna ad nostrud occaecat\",\n  \"Talrunis\": \"laboris mollit\",\n  \"ParskMen\": \"commodo deserunt\",\n  \"Sagatavotajs\": \"dolore nulla\",\n  \"NmrKods\": \"nostrud su\",\n  \"TabulaFP\": [\n    {\n      \"Vards\": \"in\",\n      \"Uzvards\": \"sunt in\",\n      \"Valsts\": \"in laborum in ullamco\",\n      \"AdrIela\": \"officia\",\n      \"AdrPilseta\": \"officia aute ad magna do\",\n      \"AdrPasts\": \"elit dolor\",\n      \"IenVeids\": \"velit adipisicing in Excepteur\",\n      \"IzmDatums\": 17,\n      \"IenSumma\": -5811443.522479072,\n      \"NodLikme\": 23853015.107451633,\n      \"NodSumma\": -35352699.91027565,\n      \"CitsPersKods\": \"Excepteur fugiat\",\n      \"LrNmrKods\": \"e\",\n      \"DzimDatums\": \"2000-01-31T00:00:00\",\n      \"ATVK\": \"enim non ipsum\"\n    },\n    {\n      \"Vards\": \"voluptate cillum laborum\",\n      \"Uzvards\": \"ut velit aliquip occaecat nulla\",\n      \"Valsts\": \"officia reprehenderit sint\",\n      \"AdrIela\": \"dese\",\n      \"AdrPilseta\": \"eu sunt\",\n      \"AdrPasts\": \"et\",\n      \"IenVeids\": \"fugiat eu\",\n      \"IzmDatums\": 16,\n      \"IenSumma\": -3921734.7059562653,\n      \"NodLikme\": 23938705.79623814,\n      \"NodSumma\": -17258687.90274711,\n      \"CitsPersKods\": \"sunt minim\",\n      \"LrNmrKods\": \"eu\",\n      \"DzimDatums\": \"2000-01-31T00:00:00\",\n      \"ATVK\": \"ea nisi irure\"\n    }\n  ],\n  \"TabulaJP\": [\n    {\n      \"Valsts\": \"ipsum eu id ea\",\n      \"AdrIela\": \"nisi mollit irure Excepteur\",\n      \"AdrPilseta\": \"cillum laborum\",\n      \"AdrPasts\": \"dolor cupidata\",\n      \"IenVeids\": \"fugiat ex consequat\",\n      \"IzmDatums\": 29,\n      \"IenSumma\": 35501102.52214521,\n      \"NodLikme\": -40720481.84149244,\n      \"NodSumma\": 73375233.76676768,\n      \"JpKods\": \"mollit est Lorem aute\",\n      \"JpNosaukums\": \"fugiat consequa\",\n      \"Piezimes\": \"veniam in\",\n      \"ATVK\": \"veniam reprehenderit esse adipisicing\"\n    },\n    {\n      \"Valsts\": \"Excepteur deserunt\",\n      \"AdrIela\": \"adipisicing labore commodo cillum in\",\n      \"AdrPilseta\": \"labore non nostrud magna\",\n      \"AdrPasts\": \"ut fugiat occaecat \",\n      \"IenVeids\": \"nisi ex commodo\",\n      \"IzmDatums\": 24,\n      \"IenSumma\": -49006663.90657453,\n      \"NodLikme\": 32085369.934580848,\n      \"NodSumma\": -55044059.760223664,\n      \"JpKods\": \"culpa voluptate dolor Duis sed\",\n      \"JpNosaukums\": \"fugiat quis occaecat qui\",\n      \"Piezimes\": \"culpa velit elit\",\n      \"ATVK\": \"Lorem voluptate aliqua ut\"\n    }\n  ],\n  \"Id\": 9851816,\n  \"UID\": \"officia incididunt quis\",\n  \"Precizejums\": false,\n  \"PrecizejamaisDokuments\": -23042510,\n  \"PrecizejumaPamatojums\": \"nostrud dolor\"\n}"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc/inrv2/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "inrv2",
            ":id"
          ],
          "variable": [
            {
              "key": "id",
              "value": "25210683",
              "description": "(Required) Dokumenta id."
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Dokuments neeksistē vai lietotājam nav tiesību.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc/inrv2/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "inrv2",
            ":id"
          ],
          "variable": [
            {
              "key": "id",
              "value": "25210683",
              "description": "(Required) Dokumenta id."
            }
          ]
        }
      },
      "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/inrv2/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "inrv2",
            ":id"
          ],
          "variable": [
            {
              "key": "id",
              "value": "25210683",
              "description": "(Required) Dokumenta id."
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}