Chilkat Online Tools

PowerBuilder / EDS API / Amatpersonu saraksts.

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JarrResp
integer li_RespStatusCode
oleobject loo_Json
string ls_VardsUzvards
string ls_PersonasKods
string ls_AmataKods
string ls_AmataNosaukums
string ls_DatumsNo
string ls_DatumsLidz
integer li_Ierednis
integer li_Aizvieto
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_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")

loo_QueryParams.UpdateString("vardsUzvards","Lorem qui in")
loo_QueryParams.UpdateString("personasKods","est i")
loo_QueryParams.UpdateString("amats","nisi cillum sed")
loo_QueryParams.UpdateString("datumsNoIntervalsNo","nisi cillum sed")
loo_QueryParams.UpdateString("datumsNoIntervalsLidz","nisi cillum sed")
loo_QueryParams.UpdateString("datumsLidzIntervalsNo","nisi cillum sed")
loo_QueryParams.UpdateString("datumsLidzIntervalsLidz","nisi cillum sed")
loo_QueryParams.UpdateString("ierednis","true")
loo_QueryParams.UpdateString("aizvieto","true")
loo_QueryParams.UpdateString("aktuals","true")
loo_QueryParams.UpdateInt("izlaistIerakstus",25210683)
loo_QueryParams.UpdateInt("atgrieztIerakstus",25210683)

loo_Http.SetRequestHeader("Accept","application/json")

loo_Resp = loo_Http.QuickRequestParams("GET","https://eds.vid.gov.lv/api/officials",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JarrResp = create oleobject
// Use "Chilkat_9_5_0.JsonArray" for versions of Chilkat < 10.0.0
li_rc = loo_JarrResp.ConnectToNewObject("Chilkat.JsonArray")

loo_JarrResp.LoadSb(loo_SbResponseBody)
loo_JarrResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JarrResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JarrResp
    return
end if

destroy loo_Resp

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

// [
//   {
//     "VardsUzvards": "Ut",
//     "PersonasKods": "consectetur ut",
//     "AmataKods": "sunt",
//     "AmataNosaukums": "commodo officia",
//     "DatumsNo": "2000-01-31T00:00:00",
//     "DatumsLidz": "2000-01-31T00:00:00",
//     "Ierednis": true,
//     "Aizvieto": true
//   },
//   {
//     "VardsUzvards": "ex elit proident aliquip",
//     "PersonasKods": "eiusmod do tempor",
//     "AmataKods": "sed ut qui dolore",
//     "AmataNosaukums": "Excepteur nostrud ut proident qui",
//     "DatumsNo": "2000-01-31T00:00:00",
//     "DatumsLidz": "2000-01-31T00:00:00",
//     "Ierednis": false,
//     "Aizvieto": false
//   }
// ]

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

i = 0
li_Count_i = loo_JarrResp.Size
do while i < li_Count_i
    loo_Json = loo_JarrResp.ObjectAt(i)
    ls_VardsUzvards = loo_Json.StringOf("VardsUzvards")
    ls_PersonasKods = loo_Json.StringOf("PersonasKods")
    ls_AmataKods = loo_Json.StringOf("AmataKods")
    ls_AmataNosaukums = loo_Json.StringOf("AmataNosaukums")
    ls_DatumsNo = loo_Json.StringOf("DatumsNo")
    ls_DatumsLidz = loo_Json.StringOf("DatumsLidz")
    li_Ierednis = loo_Json.BoolOf("Ierednis")
    li_Aizvieto = loo_Json.BoolOf("Aizvieto")
    destroy loo_Json
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JarrResp

Curl Command

curl -G -d "vardsUzvards=Lorem%20qui%20in"
	-d "personasKods=est%20i"
	-d "amats=nisi%20cillum%20sed"
	-d "datumsNoIntervalsNo=nisi%20cillum%20sed"
	-d "datumsNoIntervalsLidz=nisi%20cillum%20sed"
	-d "datumsLidzIntervalsNo=nisi%20cillum%20sed"
	-d "datumsLidzIntervalsLidz=nisi%20cillum%20sed"
	-d "ierednis=true"
	-d "aizvieto=true"
	-d "aktuals=true"
	-d "izlaistIerakstus=25210683"
	-d "atgrieztIerakstus=25210683"
	-H "Accept: application/json"
https://eds.vid.gov.lv/api/officials

Postman Collection Item JSON

{
  "name": "Amatpersonu saraksts.",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/officials?vardsUzvards=Lorem qui in&personasKods=est i&amats=nisi cillum sed&datumsNoIntervalsNo=nisi cillum sed&datumsNoIntervalsLidz=nisi cillum sed&datumsLidzIntervalsNo=nisi cillum sed&datumsLidzIntervalsLidz=nisi cillum sed&ierednis=true&aizvieto=true&aktuals=true&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "officials"
      ],
      "query": [
        {
          "key": "vardsUzvards",
          "value": "Lorem qui in",
          "description": "Vārds, Uzvārds."
        },
        {
          "key": "personasKods",
          "value": "est i",
          "description": "Personas kods."
        },
        {
          "key": "amats",
          "value": "nisi cillum sed",
          "description": "Amata nosaukums."
        },
        {
          "key": "datumsNoIntervalsNo",
          "value": "nisi cillum sed",
          "description": "Amatā stāšanās datuma intervāla sākums."
        },
        {
          "key": "datumsNoIntervalsLidz",
          "value": "nisi cillum sed",
          "description": "Amatā stāšanās datuma intervāla beigas."
        },
        {
          "key": "datumsLidzIntervalsNo",
          "value": "nisi cillum sed",
          "description": "Beidzis pildīt amata pienākumus datuma intervāla sākums."
        },
        {
          "key": "datumsLidzIntervalsLidz",
          "value": "nisi cillum sed",
          "description": "Beidzis pildīt amata pienākumus datuma intervāla beigas."
        },
        {
          "key": "ierednis",
          "value": "true",
          "description": "Vai persona ir valsts civildienesta ierēdnis."
        },
        {
          "key": "aizvieto",
          "value": "true",
          "description": "Vai amatpersonas pienākumus pilda uz laiku (aizvieto)."
        },
        {
          "key": "aktuals",
          "value": "true",
          "description": "Atgriezt tikai aktuālos ierakstus."
        },
        {
          "key": "izlaistIerakstus",
          "value": "25210683",
          "description": "No rezultāta izlaižamo ierakstu skaits."
        },
        {
          "key": "atgrieztIerakstus",
          "value": "25210683",
          "description": "Atgriežamo ierakstu skaits (max 100)."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/officials?vardsUzvards=Lorem qui in&personasKods=est i&amats=nisi cillum sed&datumsNoIntervalsNo=nisi cillum sed&datumsNoIntervalsLidz=nisi cillum sed&datumsLidzIntervalsNo=nisi cillum sed&datumsLidzIntervalsLidz=nisi cillum sed&ierednis=true&aizvieto=true&aktuals=true&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "officials"
          ],
          "query": [
            {
              "key": "vardsUzvards",
              "value": "Lorem qui in"
            },
            {
              "key": "personasKods",
              "value": "est i"
            },
            {
              "key": "amats",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsNoIntervalsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsNoIntervalsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsLidzIntervalsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsLidzIntervalsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "ierednis",
              "value": "true"
            },
            {
              "key": "aizvieto",
              "value": "true"
            },
            {
              "key": "aktuals",
              "value": "true"
            },
            {
              "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  {\n    \"VardsUzvards\": \"Ut\",\n    \"PersonasKods\": \"consectetur ut\",\n    \"AmataKods\": \"sunt\",\n    \"AmataNosaukums\": \"commodo officia\",\n    \"DatumsNo\": \"2000-01-31T00:00:00\",\n    \"DatumsLidz\": \"2000-01-31T00:00:00\",\n    \"Ierednis\": true,\n    \"Aizvieto\": true\n  },\n  {\n    \"VardsUzvards\": \"ex elit proident aliquip\",\n    \"PersonasKods\": \"eiusmod do tempor\",\n    \"AmataKods\": \"sed ut qui dolore\",\n    \"AmataNosaukums\": \"Excepteur nostrud ut proident qui\",\n    \"DatumsNo\": \"2000-01-31T00:00:00\",\n    \"DatumsLidz\": \"2000-01-31T00:00:00\",\n    \"Ierednis\": false,\n    \"Aizvieto\": false\n  }\n]"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/officials?vardsUzvards=Lorem qui in&personasKods=est i&amats=nisi cillum sed&datumsNoIntervalsNo=nisi cillum sed&datumsNoIntervalsLidz=nisi cillum sed&datumsLidzIntervalsNo=nisi cillum sed&datumsLidzIntervalsLidz=nisi cillum sed&ierednis=true&aizvieto=true&aktuals=true&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "officials"
          ],
          "query": [
            {
              "key": "vardsUzvards",
              "value": "Lorem qui in"
            },
            {
              "key": "personasKods",
              "value": "est i"
            },
            {
              "key": "amats",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsNoIntervalsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsNoIntervalsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsLidzIntervalsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsLidzIntervalsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "ierednis",
              "value": "true"
            },
            {
              "key": "aizvieto",
              "value": "true"
            },
            {
              "key": "aktuals",
              "value": "true"
            },
            {
              "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/officials?vardsUzvards=Lorem qui in&personasKods=est i&amats=nisi cillum sed&datumsNoIntervalsNo=nisi cillum sed&datumsNoIntervalsLidz=nisi cillum sed&datumsLidzIntervalsNo=nisi cillum sed&datumsLidzIntervalsLidz=nisi cillum sed&ierednis=true&aizvieto=true&aktuals=true&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "officials"
          ],
          "query": [
            {
              "key": "vardsUzvards",
              "value": "Lorem qui in"
            },
            {
              "key": "personasKods",
              "value": "est i"
            },
            {
              "key": "amats",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsNoIntervalsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsNoIntervalsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsLidzIntervalsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsLidzIntervalsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "ierednis",
              "value": "true"
            },
            {
              "key": "aizvieto",
              "value": "true"
            },
            {
              "key": "aktuals",
              "value": "true"
            },
            {
              "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/officials?vardsUzvards=Lorem qui in&personasKods=est i&amats=nisi cillum sed&datumsNoIntervalsNo=nisi cillum sed&datumsNoIntervalsLidz=nisi cillum sed&datumsLidzIntervalsNo=nisi cillum sed&datumsLidzIntervalsLidz=nisi cillum sed&ierednis=true&aizvieto=true&aktuals=true&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "officials"
          ],
          "query": [
            {
              "key": "vardsUzvards",
              "value": "Lorem qui in"
            },
            {
              "key": "personasKods",
              "value": "est i"
            },
            {
              "key": "amats",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsNoIntervalsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsNoIntervalsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsLidzIntervalsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "datumsLidzIntervalsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "ierednis",
              "value": "true"
            },
            {
              "key": "aizvieto",
              "value": "true"
            },
            {
              "key": "aktuals",
              "value": "true"
            },
            {
              "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": ""
    }
  ]
}