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/dkv5/: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": -61584328,
-- "Ceturksnis": 2,
-- "Epasts": "",
-- "Talrunis": "quis aute ",
-- "Menesis": 6,
-- "Nerezidents": true,
-- "Sagatavotajs": "aute ea",
-- "Tabula": [
-- {
-- "IenDiena": "2000-01-31T00:00:00",
-- "IenVeids": "ad sunt occaecat sint",
-- "IenKapAtsav": 19792624.554944023,
-- "IzdKapIegade": 50586860.273299366,
-- "Rokasnauda": false,
-- "f": true,
-- "l": false,
-- "IenDala": -66321869.19235421,
-- "AttiecDala": 28338763.96240291,
-- "NodoklisArv": 64925845.39672279,
-- "Apliekamais": 38871457.55627382,
-- "NodoklaLikme": 78048164.78236377,
-- "Nodoklis": -69173325.96784113
-- },
-- {
-- "IenDiena": "2000-01-31T00:00:00",
-- "IenVeids": "ea officia veniam s",
-- "IenKapAtsav": 66568302.260939986,
-- "IzdKapIegade": -68265245.33776514,
-- "Rokasnauda": true,
-- "f": true,
-- "l": true,
-- "IenDala": -68564351.41005428,
-- "AttiecDala": 50315053.6464974,
-- "NodoklisArv": -57723279.69034201,
-- "Apliekamais": 4921203.848669723,
-- "NodoklaLikme": -41705366.422067724,
-- "Nodoklis": -64341384.32557477
-- }
-- ],
-- "IenKapAtsavKopa": 99855406.01113215,
-- "IenDalaKopa": -42042965.98403743,
-- "IzdKapIegadeKopa": -17762811.825425968,
-- "AttiecDalaKopa": 50013080.066836625,
-- "NodoklisArvKopa": 75274983.84032097,
-- "ApliekamaisKopa": -78659021.824138,
-- "NodoklisKopa": -36741800.4278655,
-- "Pielikumi": [
-- {
-- "Fails": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "Komentars": "est velit"
-- },
-- {
-- "Fails": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "Komentars": "in"
-- }
-- ],
-- "Id": 86830406,
-- "UID": "id ",
-- "NmrKods": "proi",
-- "Precizejums": true,
-- "PrecizejamaisDokuments": -9668406,
-- "PrecizejumaPamatojums": "elit nisi in"
-- }
-- 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/dkv5/: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/dkv5/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
"dkv5",
":id"
],
"variable": [
{
"key": "id",
"value": "25210683",
"description": "(Required) Dokumenta id."
}
]
}
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/doc/dkv5/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
"dkv5",
":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\": -61584328,\n \"Ceturksnis\": 2,\n \"Epasts\": \"\",\n \"Talrunis\": \"quis aute \",\n \"Menesis\": 6,\n \"Nerezidents\": true,\n \"Sagatavotajs\": \"aute ea\",\n \"Tabula\": [\n {\n \"IenDiena\": \"2000-01-31T00:00:00\",\n \"IenVeids\": \"ad sunt occaecat sint\",\n \"IenKapAtsav\": 19792624.554944023,\n \"IzdKapIegade\": 50586860.273299366,\n \"Rokasnauda\": false,\n \"f\": true,\n \"l\": false,\n \"IenDala\": -66321869.19235421,\n \"AttiecDala\": 28338763.96240291,\n \"NodoklisArv\": 64925845.39672279,\n \"Apliekamais\": 38871457.55627382,\n \"NodoklaLikme\": 78048164.78236377,\n \"Nodoklis\": -69173325.96784113\n },\n {\n \"IenDiena\": \"2000-01-31T00:00:00\",\n \"IenVeids\": \"ea officia veniam s\",\n \"IenKapAtsav\": 66568302.260939986,\n \"IzdKapIegade\": -68265245.33776514,\n \"Rokasnauda\": true,\n \"f\": true,\n \"l\": true,\n \"IenDala\": -68564351.41005428,\n \"AttiecDala\": 50315053.6464974,\n \"NodoklisArv\": -57723279.69034201,\n \"Apliekamais\": 4921203.848669723,\n \"NodoklaLikme\": -41705366.422067724,\n \"Nodoklis\": -64341384.32557477\n }\n ],\n \"IenKapAtsavKopa\": 99855406.01113215,\n \"IenDalaKopa\": -42042965.98403743,\n \"IzdKapIegadeKopa\": -17762811.825425968,\n \"AttiecDalaKopa\": 50013080.066836625,\n \"NodoklisArvKopa\": 75274983.84032097,\n \"ApliekamaisKopa\": -78659021.824138,\n \"NodoklisKopa\": -36741800.4278655,\n \"Pielikumi\": [\n {\n \"Fails\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"Komentars\": \"est velit\"\n },\n {\n \"Fails\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"Komentars\": \"in\"\n }\n ],\n \"Id\": 86830406,\n \"UID\": \"id \",\n \"NmrKods\": \"proi\",\n \"Precizejums\": true,\n \"PrecizejamaisDokuments\": -9668406,\n \"PrecizejumaPamatojums\": \"elit nisi in\"\n}"
},
{
"name": "Lietotājs nav autentificēts.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/doc/dkv5/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
"dkv5",
":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/dkv5/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
"dkv5",
":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/dkv5/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc",
"dkv5",
":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": ""
}
]
}