Chilkat Online Tools

Foxpro / EDS API / Dokumenta pamatdati.

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcStrVal
LOCAL lcTips
LOCAL lcDatums
LOCAL lcTeksts
LOCAL lnId
LOCAL lcIzveidots
LOCAL lcIesniegts
LOCAL lcDokumentaVersija
LOCAL lcDokumentaVeids
LOCAL lcPeriodsNo
LOCAL lcPeriodsLidz
LOCAL lcPapildinformacija
LOCAL lnStatussId
LOCAL lcStatuss
LOCAL lnIrBridinajumi
LOCAL lnVarIesniegt
LOCAL lnVarDzest
LOCAL lnIrSanemtasAtbildes
LOCAL lnArhivets
LOCAL i
LOCAL lnCount_i

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

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

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://eds.vid.gov.lv/api/doc/:id",loSbResponseBody)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loSbResponseBody
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "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
    CANCEL
ENDIF

* 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

lnId = loJResp.IntOf("Id")
lcIzveidots = loJResp.StringOf("Izveidots")
lcIesniegts = loJResp.StringOf("Iesniegts")
lcDokumentaVersija = loJResp.StringOf("DokumentaVersija")
lcDokumentaVeids = loJResp.StringOf("DokumentaVeids")
lcPeriodsNo = loJResp.StringOf("PeriodsNo")
lcPeriodsLidz = loJResp.StringOf("PeriodsLidz")
lcPapildinformacija = loJResp.StringOf("Papildinformacija")
lnStatussId = loJResp.IntOf("StatussId")
lcStatuss = loJResp.StringOf("Statuss")
lnIrBridinajumi = loJResp.BoolOf("IrBridinajumi")
lnVarIesniegt = loJResp.BoolOf("VarIesniegt")
lnVarDzest = loJResp.BoolOf("VarDzest")
lnIrSanemtasAtbildes = loJResp.BoolOf("IrSanemtasAtbildes")
lnArhivets = loJResp.BoolOf("Arhivets")
i = 0
lnCount_i = loJResp.SizeOfArray("ParbaudesRezultats.Kluda")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("ParbaudesRezultats.Kluda[i]")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("ParbaudesRezultats.Bridinajums")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("ParbaudesRezultats.Bridinajums[i]")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("ParbaudesRezultats.Informacija")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("ParbaudesRezultats.Informacija[i]")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("ParbaudesRezultats.Apstiprinajums")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("ParbaudesRezultats.Apstiprinajums[i]")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("SanemtasAtbildes")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcTips = loJResp.StringOf("SanemtasAtbildes[i].Tips")
    lcDatums = loJResp.StringOf("SanemtasAtbildes[i].Datums")
    lcTeksts = loJResp.StringOf("SanemtasAtbildes[i].Teksts")
    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/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": ""
    }
  ]
}