lianja / EDS API / Apgādājamās personas.
Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
loHttp.SetRequestHeader("Accept","application/json")
loSbResponseBody = createobject("CkStringBuilder")
llSuccess = loHttp.QuickGetSb("https://eds.vid.gov.lv/api/reports/dependents",loSbResponseBody)
if (llSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loSbResponseBody
return
endif
loJResp = createobject("CkJsonObject")
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = .F.
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + str(lnRespStatusCode)
if (lnRespStatusCode >= 400) then
? "Response Header:"
? loHttp.LastHeader
? "Failed."
release loHttp
release loSbResponseBody
release loJResp
return
endif
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "Apgadajamie": [
// {
// "PersonasKods": "consequat ullamco Ut commodo",
// "Vards": "exercitation mollit qui",
// "Uzvards": "irure Duis",
// "DatumsNo": "2000-01-31T00:00:00",
// "DatumsLidz": "2000-01-31T00:00:00"
// },
// {
// "PersonasKods": "magna officia",
// "Vards": "exercitation Lorem",
// "Uzvards": "labore officia in dolore dolor",
// "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
i = 0
lnCount_i = loJResp.SizeOfArray("Apgadajamie")
do while i < lnCount_i
loJResp.I = i
lcPersonasKods = loJResp.StringOf("Apgadajamie[i].PersonasKods")
lcVards = loJResp.StringOf("Apgadajamie[i].Vards")
lcUzvards = loJResp.StringOf("Apgadajamie[i].Uzvards")
lcDatumsNo = loJResp.StringOf("Apgadajamie[i].DatumsNo")
lcDatumsLidz = loJResp.StringOf("Apgadajamie[i].DatumsLidz")
i = i + 1
enddo
release loHttp
release loSbResponseBody
release loJResp
Curl Command
curl -X GET
-H "Accept: application/json"
https://eds.vid.gov.lv/api/reports/dependents
Postman Collection Item JSON
{
"name": "Apgādājamās personas.",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/reports/dependents",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"dependents"
]
}
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/reports/dependents",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"dependents"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"Apgadajamie\": [\n {\n \"PersonasKods\": \"consequat ullamco Ut commodo\",\n \"Vards\": \"exercitation mollit qui\",\n \"Uzvards\": \"irure Duis\",\n \"DatumsNo\": \"2000-01-31T00:00:00\",\n \"DatumsLidz\": \"2000-01-31T00:00:00\"\n },\n {\n \"PersonasKods\": \"magna officia\",\n \"Vards\": \"exercitation Lorem\",\n \"Uzvards\": \"labore officia in dolore dolor\",\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/dependents",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"dependents"
]
}
},
"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/dependents",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"dependents"
]
}
},
"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/dependents",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"dependents"
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}