Chilkat Online Tools

C / EDS API / Pārskats par taksometru datu saņemšanu tiešsaistē.

Back to Collection Items

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

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkJsonObject queryParams;
    HCkHttpResponse resp;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *ParvadatajaRegNr;
    const char *AutovaditajaPersonasKods;
    const char *TransportlidzeklaNr;
    const char *SakumaLaiks;
    const char *BeiguLaiks;
    const char *Attalums;
    const char *BrauksanasMaksa;
    const char *NorekinuVeids;
    const char *NorekinuVeidsTeksts;
    const char *SasijasNumurs;
    const char *AbsolutaSummatoraStavoklis;
    const char *Komisija;
    const char *Izveidots;
    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_UpdateString(queryParams,"parSevi","true");
    CkJsonObject_UpdateString(queryParams,"parvadatajaRegNr","est i");
    CkJsonObject_UpdateString(queryParams,"autovaditajaPersonasKods","consectet");
    CkJsonObject_UpdateString(queryParams,"transportlidzeklaNr","ut su");
    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/reports/taxicarriages",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);

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    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);
        CkJsonObject_Dispose(jResp);
        return;
    }

    CkHttpResponse_Dispose(resp);

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

    // {
    //   "Parvadajumi": [
    //     {
    //       "ParvadatajaRegNr": "sunt sit",
    //       "AutovaditajaPersonasKods": "quis consectetur D",
    //       "TransportlidzeklaNr": "anim eu tempor",
    //       "SakumaLaiks": "2000-01-31T00:00:00",
    //       "BeiguLaiks": "2000-01-31T00:00:00",
    //       "Attalums": -56070425.264373556,
    //       "BrauksanasMaksa": -9970289.412923485,
    //       "NorekinuVeids": "paymentCard",
    //       "NorekinuVeidsTeksts": "dolor aliqua",
    //       "SasijasNumurs": "repre",
    //       "AbsolutaSummatoraStavoklis": -13456102.902620822,
    //       "Komisija": 20507354.215314552,
    //       "Izveidots": "2000-01-31T00:00:00"
    //     },
    //     {
    //       "ParvadatajaRegNr": "dolor",
    //       "AutovaditajaPersonasKods": "dolor do tempor molli",
    //       "TransportlidzeklaNr": "do eu id veniam cupidatat",
    //       "SakumaLaiks": "2000-01-31T00:00:00",
    //       "BeiguLaiks": "2000-01-31T00:00:00",
    //       "Attalums": 21856677.822087795,
    //       "BrauksanasMaksa": -65166643.49096808,
    //       "NorekinuVeids": "giftCard",
    //       "NorekinuVeidsTeksts": "co",
    //       "SasijasNumurs": "sint fugiat ea",
    //       "AbsolutaSummatoraStavoklis": -73926198.93205424,
    //       "Komisija": -8627515.159022048,
    //       "Izveidots": "2000-01-31T00:00:00"
    //     }
    //   ]
    // }

    // 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 = CkJsonObject_SizeOfArray(jResp,"Parvadajumi");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        ParvadatajaRegNr = CkJsonObject_stringOf(jResp,"Parvadajumi[i].ParvadatajaRegNr");
        AutovaditajaPersonasKods = CkJsonObject_stringOf(jResp,"Parvadajumi[i].AutovaditajaPersonasKods");
        TransportlidzeklaNr = CkJsonObject_stringOf(jResp,"Parvadajumi[i].TransportlidzeklaNr");
        SakumaLaiks = CkJsonObject_stringOf(jResp,"Parvadajumi[i].SakumaLaiks");
        BeiguLaiks = CkJsonObject_stringOf(jResp,"Parvadajumi[i].BeiguLaiks");
        Attalums = CkJsonObject_stringOf(jResp,"Parvadajumi[i].Attalums");
        BrauksanasMaksa = CkJsonObject_stringOf(jResp,"Parvadajumi[i].BrauksanasMaksa");
        NorekinuVeids = CkJsonObject_stringOf(jResp,"Parvadajumi[i].NorekinuVeids");
        NorekinuVeidsTeksts = CkJsonObject_stringOf(jResp,"Parvadajumi[i].NorekinuVeidsTeksts");
        SasijasNumurs = CkJsonObject_stringOf(jResp,"Parvadajumi[i].SasijasNumurs");
        AbsolutaSummatoraStavoklis = CkJsonObject_stringOf(jResp,"Parvadajumi[i].AbsolutaSummatoraStavoklis");
        Komisija = CkJsonObject_stringOf(jResp,"Parvadajumi[i].Komisija");
        Izveidots = CkJsonObject_stringOf(jResp,"Parvadajumi[i].Izveidots");
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkJsonObject_Dispose(queryParams);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl -G -d "parSevi=true"
	-d "parvadatajaRegNr=est%20i"
	-d "autovaditajaPersonasKods=consectet"
	-d "transportlidzeklaNr=ut%20su"
	-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/reports/taxicarriages

Postman Collection Item JSON

{
  "name": "Pārskats par taksometru datu saņemšanu tiešsaistē.",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "reports",
        "taxicarriages"
      ],
      "query": [
        {
          "key": "parSevi",
          "value": "true",
          "description": "Vai atlasīt nodokļu maksātāja vārdā saņemto informāciju."
        },
        {
          "key": "parvadatajaRegNr",
          "value": "est i",
          "description": "Pārvadātāja reģistrācijas numurs komercreģistrā."
        },
        {
          "key": "autovaditajaPersonasKods",
          "value": "consectet",
          "description": "Autovadītāja personas kods."
        },
        {
          "key": "transportlidzeklaNr",
          "value": "ut su",
          "description": "Autotransporta līdzekļa valsts reģistrācijas numurs."
        },
        {
          "key": "periodsNo",
          "value": "nisi cillum sed",
          "description": "(Required) Periods no."
        },
        {
          "key": "periodsLidz",
          "value": "nisi cillum sed",
          "description": "(Required) Periods līdz."
        },
        {
          "key": "izlaistIerakstus",
          "value": "25210683",
          "description": "(Required) No rezultāta izlaižamo ierakstu skaits."
        },
        {
          "key": "atgrieztIerakstus",
          "value": "25210683",
          "description": "(Required) Atgriežamo ierakstu skaits."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxicarriages"
          ],
          "query": [
            {
              "key": "parSevi",
              "value": "true"
            },
            {
              "key": "parvadatajaRegNr",
              "value": "est i"
            },
            {
              "key": "autovaditajaPersonasKods",
              "value": "consectet"
            },
            {
              "key": "transportlidzeklaNr",
              "value": "ut su"
            },
            {
              "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  \"Parvadajumi\": [\n    {\n      \"ParvadatajaRegNr\": \"sunt sit\",\n      \"AutovaditajaPersonasKods\": \"quis consectetur D\",\n      \"TransportlidzeklaNr\": \"anim eu tempor\",\n      \"SakumaLaiks\": \"2000-01-31T00:00:00\",\n      \"BeiguLaiks\": \"2000-01-31T00:00:00\",\n      \"Attalums\": -56070425.264373556,\n      \"BrauksanasMaksa\": -9970289.412923485,\n      \"NorekinuVeids\": \"paymentCard\",\n      \"NorekinuVeidsTeksts\": \"dolor aliqua\",\n      \"SasijasNumurs\": \"repre\",\n      \"AbsolutaSummatoraStavoklis\": -13456102.902620822,\n      \"Komisija\": 20507354.215314552,\n      \"Izveidots\": \"2000-01-31T00:00:00\"\n    },\n    {\n      \"ParvadatajaRegNr\": \"dolor\",\n      \"AutovaditajaPersonasKods\": \"dolor do tempor molli\",\n      \"TransportlidzeklaNr\": \"do eu id veniam cupidatat\",\n      \"SakumaLaiks\": \"2000-01-31T00:00:00\",\n      \"BeiguLaiks\": \"2000-01-31T00:00:00\",\n      \"Attalums\": 21856677.822087795,\n      \"BrauksanasMaksa\": -65166643.49096808,\n      \"NorekinuVeids\": \"giftCard\",\n      \"NorekinuVeidsTeksts\": \"co\",\n      \"SasijasNumurs\": \"sint fugiat ea\",\n      \"AbsolutaSummatoraStavoklis\": -73926198.93205424,\n      \"Komisija\": -8627515.159022048,\n      \"Izveidots\": \"2000-01-31T00:00:00\"\n    }\n  ]\n}"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxicarriages"
          ],
          "query": [
            {
              "key": "parSevi",
              "value": "true"
            },
            {
              "key": "parvadatajaRegNr",
              "value": "est i"
            },
            {
              "key": "autovaditajaPersonasKods",
              "value": "consectet"
            },
            {
              "key": "transportlidzeklaNr",
              "value": "ut su"
            },
            {
              "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/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxicarriages"
          ],
          "query": [
            {
              "key": "parSevi",
              "value": "true"
            },
            {
              "key": "parvadatajaRegNr",
              "value": "est i"
            },
            {
              "key": "autovaditajaPersonasKods",
              "value": "consectet"
            },
            {
              "key": "transportlidzeklaNr",
              "value": "ut su"
            },
            {
              "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/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxicarriages"
          ],
          "query": [
            {
              "key": "parSevi",
              "value": "true"
            },
            {
              "key": "parvadatajaRegNr",
              "value": "est i"
            },
            {
              "key": "autovaditajaPersonasKods",
              "value": "consectet"
            },
            {
              "key": "transportlidzeklaNr",
              "value": "ut su"
            },
            {
              "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": ""
    }
  ]
}