PowerBuilder / EDS API / Dokumenta pamatdati.
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_StrVal
string ls_Tips
string ls_Datums
string ls_Teksts
integer li_Id
string ls_Izveidots
string ls_Iesniegts
string ls_DokumentaVersija
string ls_DokumentaVeids
string ls_PeriodsNo
string ls_PeriodsLidz
string ls_Papildinformacija
integer li_StatussId
string ls_Statuss
integer li_IrBridinajumi
integer li_VarIesniegt
integer li_VarDzest
integer li_IrSanemtasAtbildes
integer li_Arhivets
integer i
integer li_Count_i
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Http.SetRequestHeader("Accept","application/json")
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Http.QuickGetSb("https://eds.vid.gov.lv/api/doc/:id",loo_SbResponseBody)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_SbResponseBody
return
end if
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Http.LastHeader
Write-Debug "Failed."
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "ParbaudesRezultats": {
// "Kluda": [
// "dolor ad aliqua",
// "commodo enim est"
// ],
// "Bridinajums": [
// "aliqua adipisicing eiusmod incididunt",
// "Ut eiusmod laborum"
// ],
// "Informacija": [
// "exercitation inc",
// "irure amet ut"
// ],
// "Apstiprinajums": [
// "labore eu magna irure",
// "dolor laboris tempor"
// ]
// },
// "SanemtasAtbildes": [
// {
// "Tips": "ex dolore amet",
// "Datums": "2000-01-31T00:00:00",
// "Teksts": "commodo sint minim"
// },
// {
// "Tips": "in laborum",
// "Datums": "2000-01-31T00:00:00",
// "Teksts": "in fugiat"
// }
// ],
// "Id": -19950873,
// "Izveidots": "2000-01-31T00:00:00",
// "Iesniegts": "2000-01-31T00:00:00",
// "DokumentaVersija": "cillum ut magna adipisicing aliqua",
// "DokumentaVeids": "ex magna reprehenderit",
// "PeriodsNo": "2000-01-31T00:00:00",
// "PeriodsLidz": "2000-01-31T00:00:00",
// "Papildinformacija": "pariatur tempor occ",
// "StatussId": 94653878,
// "Statuss": "aliquip occaec",
// "IrBridinajumi": true,
// "VarIesniegt": true,
// "VarDzest": true,
// "IrSanemtasAtbildes": true,
// "Arhivets": false
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
li_Id = loo_JResp.IntOf("Id")
ls_Izveidots = loo_JResp.StringOf("Izveidots")
ls_Iesniegts = loo_JResp.StringOf("Iesniegts")
ls_DokumentaVersija = loo_JResp.StringOf("DokumentaVersija")
ls_DokumentaVeids = loo_JResp.StringOf("DokumentaVeids")
ls_PeriodsNo = loo_JResp.StringOf("PeriodsNo")
ls_PeriodsLidz = loo_JResp.StringOf("PeriodsLidz")
ls_Papildinformacija = loo_JResp.StringOf("Papildinformacija")
li_StatussId = loo_JResp.IntOf("StatussId")
ls_Statuss = loo_JResp.StringOf("Statuss")
li_IrBridinajumi = loo_JResp.BoolOf("IrBridinajumi")
li_VarIesniegt = loo_JResp.BoolOf("VarIesniegt")
li_VarDzest = loo_JResp.BoolOf("VarDzest")
li_IrSanemtasAtbildes = loo_JResp.BoolOf("IrSanemtasAtbildes")
li_Arhivets = loo_JResp.BoolOf("Arhivets")
i = 0
li_Count_i = loo_JResp.SizeOfArray("ParbaudesRezultats.Kluda")
do while i < li_Count_i
loo_JResp.I = i
ls_StrVal = loo_JResp.StringOf("ParbaudesRezultats.Kluda[i]")
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("ParbaudesRezultats.Bridinajums")
do while i < li_Count_i
loo_JResp.I = i
ls_StrVal = loo_JResp.StringOf("ParbaudesRezultats.Bridinajums[i]")
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("ParbaudesRezultats.Informacija")
do while i < li_Count_i
loo_JResp.I = i
ls_StrVal = loo_JResp.StringOf("ParbaudesRezultats.Informacija[i]")
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("ParbaudesRezultats.Apstiprinajums")
do while i < li_Count_i
loo_JResp.I = i
ls_StrVal = loo_JResp.StringOf("ParbaudesRezultats.Apstiprinajums[i]")
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("SanemtasAtbildes")
do while i < li_Count_i
loo_JResp.I = i
ls_Tips = loo_JResp.StringOf("SanemtasAtbildes[i].Tips")
ls_Datums = loo_JResp.StringOf("SanemtasAtbildes[i].Datums")
ls_Teksts = loo_JResp.StringOf("SanemtasAtbildes[i].Teksts")
i = i + 1
loop
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -X GET
-H "Accept: application/json"
https://eds.vid.gov.lv/api/doc/:id
Postman Collection Item JSON
{
"name": "Dokumenta pamatdati.",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/doc/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
":id"
],
"variable": [
{
"key": "id",
"value": "25210683",
"description": "(Required) Dokumenta id."
}
]
}
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/doc/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
":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 \"ParbaudesRezultats\": {\n \"Kluda\": [\n \"dolor ad aliqua\",\n \"commodo enim est\"\n ],\n \"Bridinajums\": [\n \"aliqua adipisicing eiusmod incididunt\",\n \"Ut eiusmod laborum\"\n ],\n \"Informacija\": [\n \"exercitation inc\",\n \"irure amet ut\"\n ],\n \"Apstiprinajums\": [\n \"labore eu magna irure\",\n \"dolor laboris tempor\"\n ]\n },\n \"SanemtasAtbildes\": [\n {\n \"Tips\": \"ex dolore amet\",\n \"Datums\": \"2000-01-31T00:00:00\",\n \"Teksts\": \"commodo sint minim\"\n },\n {\n \"Tips\": \"in laborum\",\n \"Datums\": \"2000-01-31T00:00:00\",\n \"Teksts\": \"in fugiat\"\n }\n ],\n \"Id\": -19950873,\n \"Izveidots\": \"2000-01-31T00:00:00\",\n \"Iesniegts\": \"2000-01-31T00:00:00\",\n \"DokumentaVersija\": \"cillum ut magna adipisicing aliqua\",\n \"DokumentaVeids\": \"ex magna reprehenderit\",\n \"PeriodsNo\": \"2000-01-31T00:00:00\",\n \"PeriodsLidz\": \"2000-01-31T00:00:00\",\n \"Papildinformacija\": \"pariatur tempor occ\",\n \"StatussId\": 94653878,\n \"Statuss\": \"aliquip occaec\",\n \"IrBridinajumi\": true,\n \"VarIesniegt\": true,\n \"VarDzest\": true,\n \"IrSanemtasAtbildes\": true,\n \"Arhivets\": false\n}"
},
{
"name": "Lietotājs nav autentificēts.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/doc/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
":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/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
":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/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
":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": ""
}
]
}