Chilkat Online Tools

unicodeC / EDS API / Dokuments "Mikrouzņēmumu nodokļa deklarācija".

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 *Kods;
    const wchar_t *VardsUzvards;
    BOOL IrIpasnieks;
    const wchar_t *IenakMen1;
    const wchar_t *IenakMen2;
    const wchar_t *IenakMen3;
    const wchar_t *Epasts;
    const wchar_t *Talrunis;
    int Gads;
    int Ceturksnis;
    const wchar_t *Sagatavotajs;
    const wchar_t *InformacijaPielasita;
    int JurForma;
    const wchar_t *IenakumiVaiApgrozijums;
    const wchar_t *R1_1;
    const wchar_t *R1_2;
    const wchar_t *R1_3;
    const wchar_t *R1;
    const wchar_t *R2_1;
    const wchar_t *R2_2;
    const wchar_t *R2_3;
    const wchar_t *R2_4;
    const wchar_t *R2;
    int Id;
    const wchar_t *UID;
    const wchar_t *NmrKods;
    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/mnv4/: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)

    // {
    //   "Epasts": "enim amet non ",
    //   "Talrunis": "id c",
    //   "Gads": 64835712,
    //   "Ceturksnis": 1,
    //   "Sagatavotajs": "nisi",
    //   "InformacijaPielasita": "2000-01-31T00:00:00",
    //   "JurForma": 88603509,
    //   "IenakumiVaiApgrozijums": "sint cillum",
    //   "R1_1": 31349873.20691654,
    //   "R1_2": -37608797.88134388,
    //   "R1_3": 82418688.5669148,
    //   "R1": 2542464.1702338904,
    //   "R2_1": 46996023.13942307,
    //   "R2_2": -17110660.40645033,
    //   "R2_3": -5204022.378950328,
    //   "R2_4": -18264132.106288895,
    //   "R2": -90810971.90093508,
    //   "R3": [
    //     {
    //       "Kods": "anim ut",
    //       "VardsUzvards": "Duis aute id eu",
    //       "IrIpasnieks": false,
    //       "IenakMen1": 38815983.25991592,
    //       "IenakMen2": -84487767.18798548,
    //       "IenakMen3": 16457643.991805598
    //     },
    //     {
    //       "Kods": "adipisicing ipsum",
    //       "VardsUzvards": "nostrud voluptate enim",
    //       "IrIpasnieks": true,
    //       "IenakMen1": -18313320.85834609,
    //       "IenakMen2": -89228798.3221939,
    //       "IenakMen3": -86944379.0592796
    //     }
    //   ],
    //   "Id": -51804961,
    //   "UID": "culpa esse nostrud",
    //   "NmrKods": "officia s",
    //   "Precizejums": true,
    //   "PrecizejamaisDokuments": 23637004,
    //   "PrecizejumaPamatojums": "Lorem ad ut magna"
    // }

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

    Epasts = CkJsonObjectW_stringOf(jResp,L"Epasts");
    Talrunis = CkJsonObjectW_stringOf(jResp,L"Talrunis");
    Gads = CkJsonObjectW_IntOf(jResp,L"Gads");
    Ceturksnis = CkJsonObjectW_IntOf(jResp,L"Ceturksnis");
    Sagatavotajs = CkJsonObjectW_stringOf(jResp,L"Sagatavotajs");
    InformacijaPielasita = CkJsonObjectW_stringOf(jResp,L"InformacijaPielasita");
    JurForma = CkJsonObjectW_IntOf(jResp,L"JurForma");
    IenakumiVaiApgrozijums = CkJsonObjectW_stringOf(jResp,L"IenakumiVaiApgrozijums");
    R1_1 = CkJsonObjectW_stringOf(jResp,L"R1_1");
    R1_2 = CkJsonObjectW_stringOf(jResp,L"R1_2");
    R1_3 = CkJsonObjectW_stringOf(jResp,L"R1_3");
    R1 = CkJsonObjectW_stringOf(jResp,L"R1");
    R2_1 = CkJsonObjectW_stringOf(jResp,L"R2_1");
    R2_2 = CkJsonObjectW_stringOf(jResp,L"R2_2");
    R2_3 = CkJsonObjectW_stringOf(jResp,L"R2_3");
    R2_4 = CkJsonObjectW_stringOf(jResp,L"R2_4");
    R2 = CkJsonObjectW_stringOf(jResp,L"R2");
    Id = CkJsonObjectW_IntOf(jResp,L"Id");
    UID = CkJsonObjectW_stringOf(jResp,L"UID");
    NmrKods = CkJsonObjectW_stringOf(jResp,L"NmrKods");
    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"R3");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        Kods = CkJsonObjectW_stringOf(jResp,L"R3[i].Kods");
        VardsUzvards = CkJsonObjectW_stringOf(jResp,L"R3[i].VardsUzvards");
        IrIpasnieks = CkJsonObjectW_BoolOf(jResp,L"R3[i].IrIpasnieks");
        IenakMen1 = CkJsonObjectW_stringOf(jResp,L"R3[i].IenakMen1");
        IenakMen2 = CkJsonObjectW_stringOf(jResp,L"R3[i].IenakMen2");
        IenakMen3 = CkJsonObjectW_stringOf(jResp,L"R3[i].IenakMen3");
        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/mnv4/:id

Postman Collection Item JSON

{
  "name": "Dokuments \"Mikrouzņēmumu nodokļa deklarācija\".",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/doc/mnv4/:id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "doc",
        "mnv4",
        ":id"
      ],
      "variable": [
        {
          "key": "id",
          "value": "25210683",
          "description": "(Required) Dokumenta id."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc/mnv4/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "mnv4",
            ":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  \"Epasts\": \"enim amet non \",\n  \"Talrunis\": \"id c\",\n  \"Gads\": 64835712,\n  \"Ceturksnis\": 1,\n  \"Sagatavotajs\": \"nisi\",\n  \"InformacijaPielasita\": \"2000-01-31T00:00:00\",\n  \"JurForma\": 88603509,\n  \"IenakumiVaiApgrozijums\": \"sint cillum\",\n  \"R1_1\": 31349873.20691654,\n  \"R1_2\": -37608797.88134388,\n  \"R1_3\": 82418688.5669148,\n  \"R1\": 2542464.1702338904,\n  \"R2_1\": 46996023.13942307,\n  \"R2_2\": -17110660.40645033,\n  \"R2_3\": -5204022.378950328,\n  \"R2_4\": -18264132.106288895,\n  \"R2\": -90810971.90093508,\n  \"R3\": [\n    {\n      \"Kods\": \"anim ut\",\n      \"VardsUzvards\": \"Duis aute id eu\",\n      \"IrIpasnieks\": false,\n      \"IenakMen1\": 38815983.25991592,\n      \"IenakMen2\": -84487767.18798548,\n      \"IenakMen3\": 16457643.991805598\n    },\n    {\n      \"Kods\": \"adipisicing ipsum\",\n      \"VardsUzvards\": \"nostrud voluptate enim\",\n      \"IrIpasnieks\": true,\n      \"IenakMen1\": -18313320.85834609,\n      \"IenakMen2\": -89228798.3221939,\n      \"IenakMen3\": -86944379.0592796\n    }\n  ],\n  \"Id\": -51804961,\n  \"UID\": \"culpa esse nostrud\",\n  \"NmrKods\": \"officia s\",\n  \"Precizejums\": true,\n  \"PrecizejamaisDokuments\": 23637004,\n  \"PrecizejumaPamatojums\": \"Lorem ad ut magna\"\n}"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc/mnv4/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "mnv4",
            ":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/mnv4/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "mnv4",
            ":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/mnv4/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "mnv4",
            ":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": ""
    }
  ]
}