unicodeC / EDS API / Apstiprinātās rezidenta apliecības - iesniegumi nodokļu atvieglojumu piemērošanai.
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW queryParams;
HCkHttpResponseW resp;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *Nosaukums;
const wchar_t *IenakumuVeids;
const wchar_t *RezidencesValsts;
const wchar_t *DatumsNo;
const wchar_t *DatumsLidz;
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();
queryParams = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(queryParams,L"periodsNo",L"nisi cillum sed");
CkJsonObjectW_UpdateString(queryParams,L"periodsLidz",L"nisi cillum sed");
CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");
resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://eds.vid.gov.lv/api/reports/certificatesofresidency",queryParams);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
return;
}
sbResponseBody = CkStringBuilderW_Create();
CkHttpResponseW_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpResponseW_getStatusCode(resp);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpResponseW_header(resp));
wprintf(L"Failed.\n");
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
CkHttpResponseW_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "RezidentaApliecibas": [
// {
// "Nosaukums": "sunt reprehenderit cillum Excepteur",
// "IenakumuVeids": "laboris tempor nisi reprehenderit",
// "RezidencesValsts": "aliqua deserunt labore laborum do",
// "DatumsNo": "2000-01-31T00:00:00",
// "DatumsLidz": "2000-01-31T00:00:00"
// },
// {
// "Nosaukums": "eni",
// "IenakumuVeids": "cupid",
// "RezidencesValsts": "non quis adipisicing",
// "DatumsNo": "2000-01-31T00:00:00",
// "DatumsLidz": "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 = CkJsonObjectW_SizeOfArray(jResp,L"RezidentaApliecibas");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
Nosaukums = CkJsonObjectW_stringOf(jResp,L"RezidentaApliecibas[i].Nosaukums");
IenakumuVeids = CkJsonObjectW_stringOf(jResp,L"RezidentaApliecibas[i].IenakumuVeids");
RezidencesValsts = CkJsonObjectW_stringOf(jResp,L"RezidentaApliecibas[i].RezidencesValsts");
DatumsNo = CkJsonObjectW_stringOf(jResp,L"RezidentaApliecibas[i].DatumsNo");
DatumsLidz = CkJsonObjectW_stringOf(jResp,L"RezidentaApliecibas[i].DatumsLidz");
i = i + 1;
}
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -G -d "periodsNo=nisi%20cillum%20sed"
-d "periodsLidz=nisi%20cillum%20sed"
-H "Accept: application/json"
https://eds.vid.gov.lv/api/reports/certificatesofresidency
Postman Collection Item JSON
{
"name": "Apstiprinātās rezidenta apliecības - iesniegumi nodokļu atvieglojumu piemērošanai.",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/reports/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed",
"description": "(Required) Periods no."
},
{
"key": "periodsLidz",
"value": "nisi cillum sed",
"description": "(Required) Periods līdz."
}
]
}
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/reports/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"RezidentaApliecibas\": [\n {\n \"Nosaukums\": \"sunt reprehenderit cillum Excepteur\",\n \"IenakumuVeids\": \"laboris tempor nisi reprehenderit\",\n \"RezidencesValsts\": \"aliqua deserunt labore laborum do\",\n \"DatumsNo\": \"2000-01-31T00:00:00\",\n \"DatumsLidz\": \"2000-01-31T00:00:00\"\n },\n {\n \"Nosaukums\": \"eni\",\n \"IenakumuVeids\": \"cupid\",\n \"RezidencesValsts\": \"non quis adipisicing\",\n \"DatumsNo\": \"2000-01-31T00:00:00\",\n \"DatumsLidz\": \"2000-01-31T00:00:00\"\n }\n ]\n}"
},
{
"name": "Lietotājs nav autentificēts.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/reports/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
}
]
}
},
"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/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
}
]
}
},
"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/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}