Chilkat Online Tools

SQL Server / EDS API / Dokuments "Pārskata perioda deklarācija par ienākumu no kapitāla pieauguma - DK veidlapa".

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'

    DECLARE @sbResponseBody int
    -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://eds.vid.gov.lv/api/doc/dkv4/:id', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jResp int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END

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

    -- {
    --   "Gads": 11046139,
    --   "Ceturksnis": 2,
    --   "Epasts": "D|s.aWd.Ghp.+y~~gG.0u@ADmX.cvEņPYv.ģK.ZkvaXHžmd2.Mč.x49ķ.VJX.ZTņC\"j (i\"@ew6jB8kCp.w6DDsi.Q14eZxB9b.DhWūU7L.dRrT6šcKF.fWn-būVyķxč.IFgwap.JIZ0R.=UD^Dqz@Sp83n.h.hFWģmQpmw7.ņekC\"e1fe$+I\"@TLQl6U.ērH.tcdmņhNIF.p'|PxBG~YDF.-.r5e&?.P.{D|.Sj=ebutIHX`.JkK#.5O|$.`qdPxW@RZuurxS.ltPhfIbJ.qķ.ā0.č0Lē.9UK2aH.žAOfD.qHVKoB\"7,?N\"@ē.8LēIi.3kU.bvua2Cc9As.ģ8o.Wnjl661mP.pj.zNa.cY92aygņ.RģmčxawMņķZkf.+/v.q=.WiEp.3I1@8čMllNg.Swekņuģbpj.sn8pH.ž5čWņM9ģ.IRjEž\"W9u'\"@aņ.xDYG8uģū.adwGFxtvUžN\"A*o?AG62\"@ūn.SZ.V0c79n4R7.8y8ļžENC4ā.nDd4.ģgrgģHu.XOIfTšk",
    --   "Talrunis": "commodo ani",
    --   "Menesis": 11,
    --   "Nerezidents": false,
    --   "Sagatavotajs": "labore cillum Excepteur",
    --   "Tabula": [
    --     {
    --       "IenDiena": "2000-01-31T00:00:00",
    --       "IenVeids": "laborum enim cillum ut",
    --       "IenKapAtsav": -85377526.6068494,
    --       "IzdKapIegade": 99427016.18937537,
    --       "Rokasnauda": false,
    --       "f": false,
    --       "l": false,
    --       "IenDala": -99106888.30366218,
    --       "AttiecDala": 90085134.97753322,
    --       "NodoklisArv": -79564588.40644798,
    --       "Apliekamais": -98527483.08932595,
    --       "NodoklaLikme": -19096382.238948405,
    --       "Nodoklis": 87505428.48247945
    --     },
    --     {
    --       "IenDiena": "2000-01-31T00:00:00",
    --       "IenVeids": "et eu elit",
    --       "IenKapAtsav": 99723613.25270417,
    --       "IzdKapIegade": -81552051.365935,
    --       "Rokasnauda": true,
    --       "f": false,
    --       "l": false,
    --       "IenDala": 75927506.23488888,
    --       "AttiecDala": -98277746.07004711,
    --       "NodoklisArv": -51123324.683856584,
    --       "Apliekamais": -59093649.1943669,
    --       "NodoklaLikme": 25466112.986774504,
    --       "Nodoklis": 85640398.89682516
    --     }
    --   ],
    --   "IenKapAtsavKopa": 45020903.88674405,
    --   "IenDalaKopa": 73361182.48541239,
    --   "IzdKapIegadeKopa": -19078178.033489704,
    --   "AttiecDalaKopa": -76746679.2491915,
    --   "NodoklisArvKopa": -64727441.638586566,
    --   "ApliekamaisKopa": 24953573.448955208,
    --   "NodoklisKopa": 44482056.88053179,
    --   "Pielikumi": [
    --     {
    --       "Fails": {
    --         "value": "<Error: Too many levels of nesting to fake this schema>"
    --       },
    --       "Komentars": "tempor fugiat anim amet non"
    --     },
    --     {
    --       "Fails": {
    --         "value": "<Error: Too many levels of nesting to fake this schema>"
    --       },
    --       "Komentars": "elit dolor do ut"
    --     }
    --   ],
    --   "Id": 28894547,
    --   "UID": "sit enim reprehenderit",
    --   "NmrKods": "v",
    --   "Precizejums": true,
    --   "PrecizejamaisDokuments": 92679988,
    --   "PrecizejumaPamatojums": "ex Excepteur"
    -- }

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

    DECLARE @IenDiena nvarchar(4000)

    DECLARE @IenVeids nvarchar(4000)

    DECLARE @IenKapAtsav nvarchar(4000)

    DECLARE @IzdKapIegade nvarchar(4000)

    DECLARE @Rokasnauda int

    DECLARE @f int

    DECLARE @l int

    DECLARE @IenDala nvarchar(4000)

    DECLARE @AttiecDala nvarchar(4000)

    DECLARE @NodoklisArv nvarchar(4000)

    DECLARE @Apliekamais nvarchar(4000)

    DECLARE @NodoklaLikme nvarchar(4000)

    DECLARE @Nodoklis nvarchar(4000)

    DECLARE @Value nvarchar(4000)

    DECLARE @Komentars nvarchar(4000)

    DECLARE @Gads int
    EXEC sp_OAMethod @jResp, 'IntOf', @Gads OUT, 'Gads'
    DECLARE @Ceturksnis int
    EXEC sp_OAMethod @jResp, 'IntOf', @Ceturksnis OUT, 'Ceturksnis'
    DECLARE @Epasts nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Epasts OUT, 'Epasts'
    DECLARE @Talrunis nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Talrunis OUT, 'Talrunis'
    DECLARE @Menesis int
    EXEC sp_OAMethod @jResp, 'IntOf', @Menesis OUT, 'Menesis'
    DECLARE @Nerezidents int
    EXEC sp_OAMethod @jResp, 'BoolOf', @Nerezidents OUT, 'Nerezidents'
    DECLARE @Sagatavotajs nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Sagatavotajs OUT, 'Sagatavotajs'
    DECLARE @IenKapAtsavKopa nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @IenKapAtsavKopa OUT, 'IenKapAtsavKopa'
    DECLARE @IenDalaKopa nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @IenDalaKopa OUT, 'IenDalaKopa'
    DECLARE @IzdKapIegadeKopa nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @IzdKapIegadeKopa OUT, 'IzdKapIegadeKopa'
    DECLARE @AttiecDalaKopa nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @AttiecDalaKopa OUT, 'AttiecDalaKopa'
    DECLARE @NodoklisArvKopa nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @NodoklisArvKopa OUT, 'NodoklisArvKopa'
    DECLARE @ApliekamaisKopa nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ApliekamaisKopa OUT, 'ApliekamaisKopa'
    DECLARE @NodoklisKopa nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @NodoklisKopa OUT, 'NodoklisKopa'
    DECLARE @Id int
    EXEC sp_OAMethod @jResp, 'IntOf', @Id OUT, 'Id'
    DECLARE @UID nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @UID OUT, 'UID'
    DECLARE @NmrKods nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @NmrKods OUT, 'NmrKods'
    DECLARE @Precizejums int
    EXEC sp_OAMethod @jResp, 'BoolOf', @Precizejums OUT, 'Precizejums'
    DECLARE @PrecizejamaisDokuments int
    EXEC sp_OAMethod @jResp, 'IntOf', @PrecizejamaisDokuments OUT, 'PrecizejamaisDokuments'
    DECLARE @PrecizejumaPamatojums nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @PrecizejumaPamatojums OUT, 'PrecizejumaPamatojums'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'Tabula'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @IenDiena OUT, 'Tabula[i].IenDiena'
        EXEC sp_OAMethod @jResp, 'StringOf', @IenVeids OUT, 'Tabula[i].IenVeids'
        EXEC sp_OAMethod @jResp, 'StringOf', @IenKapAtsav OUT, 'Tabula[i].IenKapAtsav'
        EXEC sp_OAMethod @jResp, 'StringOf', @IzdKapIegade OUT, 'Tabula[i].IzdKapIegade'
        EXEC sp_OAMethod @jResp, 'BoolOf', @Rokasnauda OUT, 'Tabula[i].Rokasnauda'
        EXEC sp_OAMethod @jResp, 'BoolOf', @f OUT, 'Tabula[i].f'
        EXEC sp_OAMethod @jResp, 'BoolOf', @l OUT, 'Tabula[i].l'
        EXEC sp_OAMethod @jResp, 'StringOf', @IenDala OUT, 'Tabula[i].IenDala'
        EXEC sp_OAMethod @jResp, 'StringOf', @AttiecDala OUT, 'Tabula[i].AttiecDala'
        EXEC sp_OAMethod @jResp, 'StringOf', @NodoklisArv OUT, 'Tabula[i].NodoklisArv'
        EXEC sp_OAMethod @jResp, 'StringOf', @Apliekamais OUT, 'Tabula[i].Apliekamais'
        EXEC sp_OAMethod @jResp, 'StringOf', @NodoklaLikme OUT, 'Tabula[i].NodoklaLikme'
        EXEC sp_OAMethod @jResp, 'StringOf', @Nodoklis OUT, 'Tabula[i].Nodoklis'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'Pielikumi'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'Pielikumi[i].Fails.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @Komentars OUT, 'Pielikumi[i].Komentars'
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

Curl Command

curl -X GET
	-H "Accept: application/json"
https://eds.vid.gov.lv/api/doc/dkv4/:id

Postman Collection Item JSON

{
  "name": "Dokuments \"Pārskata perioda deklarācija par ienākumu no kapitāla pieauguma - DK veidlapa\".",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/doc/dkv4/:id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "doc",
        "dkv4",
        ":id"
      ],
      "variable": [
        {
          "key": "id",
          "value": "25210683",
          "description": "(Required) Dokumenta id."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc/dkv4/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "dkv4",
            ":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  \"Gads\": 11046139,\n  \"Ceturksnis\": 2,\n  \"Epasts\": \"D|s.aWd.Ghp.+y~~gG.0u@ADmX.cvEņPYv.ģK.ZkvaXHžmd2.Mč.x49ķ.VJX.ZTņC\\\"j (i\\\"@ew6jB8kCp.w6DDsi.Q14eZxB9b.DhWūU7L.dRrT6šcKF.fWn-būVyķxč.IFgwap.JIZ0R.=UD^Dqz@Sp83n.h.hFWģmQpmw7.ņekC\\\"e1fe$+I\\\"@TLQl6U.ērH.tcdmņhNIF.p'|PxBG~YDF.-.r5e&?.P.{D|.Sj=ebutIHX`.JkK#.5O|$.`qdPxW@RZuurxS.ltPhfIbJ.qķ.ā0.č0Lē.9UK2aH.žAOfD.qHVKoB\\\"7,?N\\\"@ē.8LēIi.3kU.bvua2Cc9As.ģ8o.Wnjl661mP.pj.zNa.cY92aygņ.RģmčxawMņķZkf.+/v.q=.WiEp.3I1@8čMllNg.Swekņuģbpj.sn8pH.ž5čWņM9ģ.IRjEž\\\"W9u'\\\"@aņ.xDYG8uģū.adwGFxtvUžN\\\"A*o?AG62\\\"@ūn.SZ.V0c79n4R7.8y8ļžENC4ā.nDd4.ģgrgģHu.XOIfTšk\",\n  \"Talrunis\": \"commodo ani\",\n  \"Menesis\": 11,\n  \"Nerezidents\": false,\n  \"Sagatavotajs\": \"labore cillum Excepteur\",\n  \"Tabula\": [\n    {\n      \"IenDiena\": \"2000-01-31T00:00:00\",\n      \"IenVeids\": \"laborum enim cillum ut\",\n      \"IenKapAtsav\": -85377526.6068494,\n      \"IzdKapIegade\": 99427016.18937537,\n      \"Rokasnauda\": false,\n      \"f\": false,\n      \"l\": false,\n      \"IenDala\": -99106888.30366218,\n      \"AttiecDala\": 90085134.97753322,\n      \"NodoklisArv\": -79564588.40644798,\n      \"Apliekamais\": -98527483.08932595,\n      \"NodoklaLikme\": -19096382.238948405,\n      \"Nodoklis\": 87505428.48247945\n    },\n    {\n      \"IenDiena\": \"2000-01-31T00:00:00\",\n      \"IenVeids\": \"et eu elit\",\n      \"IenKapAtsav\": 99723613.25270417,\n      \"IzdKapIegade\": -81552051.365935,\n      \"Rokasnauda\": true,\n      \"f\": false,\n      \"l\": false,\n      \"IenDala\": 75927506.23488888,\n      \"AttiecDala\": -98277746.07004711,\n      \"NodoklisArv\": -51123324.683856584,\n      \"Apliekamais\": -59093649.1943669,\n      \"NodoklaLikme\": 25466112.986774504,\n      \"Nodoklis\": 85640398.89682516\n    }\n  ],\n  \"IenKapAtsavKopa\": 45020903.88674405,\n  \"IenDalaKopa\": 73361182.48541239,\n  \"IzdKapIegadeKopa\": -19078178.033489704,\n  \"AttiecDalaKopa\": -76746679.2491915,\n  \"NodoklisArvKopa\": -64727441.638586566,\n  \"ApliekamaisKopa\": 24953573.448955208,\n  \"NodoklisKopa\": 44482056.88053179,\n  \"Pielikumi\": [\n    {\n      \"Fails\": {\n        \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"Komentars\": \"tempor fugiat anim amet non\"\n    },\n    {\n      \"Fails\": {\n        \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"Komentars\": \"elit dolor do ut\"\n    }\n  ],\n  \"Id\": 28894547,\n  \"UID\": \"sit enim reprehenderit\",\n  \"NmrKods\": \"v\",\n  \"Precizejums\": true,\n  \"PrecizejamaisDokuments\": 92679988,\n  \"PrecizejumaPamatojums\": \"ex Excepteur\"\n}"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/doc/dkv4/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "dkv4",
            ":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/dkv4/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "dkv4",
            ":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/dkv4/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "doc",
            "dkv4",
            ":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": ""
    }
  ]
}