SQL Server / EDS API / Dokumentu saraksts.
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
DECLARE @iTmp0 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
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'id', 25210683
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'dokumentaVeidsKods', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'statussId', 25210683
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'izveidotsNo', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'izveidotsLidz', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'iesniegtsNo', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'iesniegtsLidz', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'periodsNo', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'periodsLidz', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'izlaistIerakstus', 25210683
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'atgrieztIerakstus', 25210683
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://eds.vid.gov.lv/api/doc', @queryParams
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
RETURN
END
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 @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jarrResp int
-- Use "Chilkat_9_5_0.JsonArray" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonArray', @jarrResp OUT
EXEC sp_OAMethod @jarrResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jarrResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jarrResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jarrResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- [
-- {
-- "Id": 63381534,
-- "Izveidots": "2000-01-31T00:00:00",
-- "Iesniegts": "2000-01-31T00:00:00",
-- "DokumentaVersija": "ut aute enim et pariatur",
-- "DokumentaVeids": "commodo",
-- "PeriodsNo": "2000-01-31T00:00:00",
-- "PeriodsLidz": "2000-01-31T00:00:00",
-- "Papildinformacija": "in mollit Ut",
-- "StatussId": -47605421,
-- "Statuss": "Lorem",
-- "IrBridinajumi": true,
-- "VarIesniegt": true,
-- "VarDzest": false,
-- "IrSanemtasAtbildes": false,
-- "Arhivets": false
-- },
-- {
-- "Id": 48168202,
-- "Izveidots": "2000-01-31T00:00:00",
-- "Iesniegts": "2000-01-31T00:00:00",
-- "DokumentaVersija": "est dolor in non dolore",
-- "DokumentaVeids": "minim amet",
-- "PeriodsNo": "2000-01-31T00:00:00",
-- "PeriodsLidz": "2000-01-31T00:00:00",
-- "Papildinformacija": "cillum mollit occaecat eiusmod",
-- "StatussId": -94109410,
-- "Statuss": "laborum incididunt consectetur",
-- "IrBridinajumi": false,
-- "VarIesniegt": false,
-- "VarDzest": false,
-- "IrSanemtasAtbildes": false,
-- "Arhivets": true
-- }
-- ]
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @json int
DECLARE @Id int
DECLARE @Izveidots nvarchar(4000)
DECLARE @Iesniegts nvarchar(4000)
DECLARE @DokumentaVersija nvarchar(4000)
DECLARE @DokumentaVeids nvarchar(4000)
DECLARE @PeriodsNo nvarchar(4000)
DECLARE @PeriodsLidz nvarchar(4000)
DECLARE @Papildinformacija nvarchar(4000)
DECLARE @StatussId int
DECLARE @Statuss nvarchar(4000)
DECLARE @IrBridinajumi int
DECLARE @VarIesniegt int
DECLARE @VarDzest int
DECLARE @IrSanemtasAtbildes int
DECLARE @Arhivets int
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAGetProperty @jarrResp, 'Size', @count_i OUT
WHILE @i < @count_i
BEGIN
EXEC sp_OAMethod @jarrResp, 'ObjectAt', @json OUT, @i
EXEC sp_OAMethod @json, 'IntOf', @Id OUT, 'Id'
EXEC sp_OAMethod @json, 'StringOf', @Izveidots OUT, 'Izveidots'
EXEC sp_OAMethod @json, 'StringOf', @Iesniegts OUT, 'Iesniegts'
EXEC sp_OAMethod @json, 'StringOf', @DokumentaVersija OUT, 'DokumentaVersija'
EXEC sp_OAMethod @json, 'StringOf', @DokumentaVeids OUT, 'DokumentaVeids'
EXEC sp_OAMethod @json, 'StringOf', @PeriodsNo OUT, 'PeriodsNo'
EXEC sp_OAMethod @json, 'StringOf', @PeriodsLidz OUT, 'PeriodsLidz'
EXEC sp_OAMethod @json, 'StringOf', @Papildinformacija OUT, 'Papildinformacija'
EXEC sp_OAMethod @json, 'IntOf', @StatussId OUT, 'StatussId'
EXEC sp_OAMethod @json, 'StringOf', @Statuss OUT, 'Statuss'
EXEC sp_OAMethod @json, 'BoolOf', @IrBridinajumi OUT, 'IrBridinajumi'
EXEC sp_OAMethod @json, 'BoolOf', @VarIesniegt OUT, 'VarIesniegt'
EXEC sp_OAMethod @json, 'BoolOf', @VarDzest OUT, 'VarDzest'
EXEC sp_OAMethod @json, 'BoolOf', @IrSanemtasAtbildes OUT, 'IrSanemtasAtbildes'
EXEC sp_OAMethod @json, 'BoolOf', @Arhivets OUT, 'Arhivets'
EXEC @hr = sp_OADestroy @json
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jarrResp
END
GO
Curl Command
curl -G -d "id=25210683"
-d "dokumentaVeidsKods=nisi%20cillum%20sed"
-d "statussId=25210683"
-d "izveidotsNo=nisi%20cillum%20sed"
-d "izveidotsLidz=nisi%20cillum%20sed"
-d "iesniegtsNo=nisi%20cillum%20sed"
-d "iesniegtsLidz=nisi%20cillum%20sed"
-d "periodsNo=nisi%20cillum%20sed"
-d "periodsLidz=nisi%20cillum%20sed"
-d "izlaistIerakstus=25210683"
-d "atgrieztIerakstus=25210683"
-H "Accept: application/json"
https://eds.vid.gov.lv/api/doc
Postman Collection Item JSON
{
"name": "Dokumentu saraksts.",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc"
],
"query": [
{
"key": "id",
"value": "25210683",
"description": "Dokumenta numurs."
},
{
"key": "dokumentaVeidsKods",
"value": "nisi cillum sed",
"description": "Dokumenta veida kods."
},
{
"key": "statussId",
"value": "25210683",
"description": "Dokumenta statusa id."
},
{
"key": "izveidotsNo",
"value": "nisi cillum sed",
"description": "Dokumenta izveidošanas datums (no)."
},
{
"key": "izveidotsLidz",
"value": "nisi cillum sed",
"description": "Dokumenta izveidošanas datums (līdz)."
},
{
"key": "iesniegtsNo",
"value": "nisi cillum sed",
"description": "Dokumenta iesniegšanas datums (no)."
},
{
"key": "iesniegtsLidz",
"value": "nisi cillum sed",
"description": "Dokumenta iesniegšanas datums (līdz)."
},
{
"key": "periodsNo",
"value": "nisi cillum sed",
"description": "Dokumenta perioda sākums."
},
{
"key": "periodsLidz",
"value": "nisi cillum sed",
"description": "Dokumenta perioda beigas."
},
{
"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/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc"
],
"query": [
{
"key": "id",
"value": "25210683"
},
{
"key": "dokumentaVeidsKods",
"value": "nisi cillum sed"
},
{
"key": "statussId",
"value": "25210683"
},
{
"key": "izveidotsNo",
"value": "nisi cillum sed"
},
{
"key": "izveidotsLidz",
"value": "nisi cillum sed"
},
{
"key": "iesniegtsNo",
"value": "nisi cillum sed"
},
{
"key": "iesniegtsLidz",
"value": "nisi cillum sed"
},
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
},
{
"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 \"Id\": 63381534,\n \"Izveidots\": \"2000-01-31T00:00:00\",\n \"Iesniegts\": \"2000-01-31T00:00:00\",\n \"DokumentaVersija\": \"ut aute enim et pariatur\",\n \"DokumentaVeids\": \"commodo\",\n \"PeriodsNo\": \"2000-01-31T00:00:00\",\n \"PeriodsLidz\": \"2000-01-31T00:00:00\",\n \"Papildinformacija\": \"in mollit Ut\",\n \"StatussId\": -47605421,\n \"Statuss\": \"Lorem\",\n \"IrBridinajumi\": true,\n \"VarIesniegt\": true,\n \"VarDzest\": false,\n \"IrSanemtasAtbildes\": false,\n \"Arhivets\": false\n },\n {\n \"Id\": 48168202,\n \"Izveidots\": \"2000-01-31T00:00:00\",\n \"Iesniegts\": \"2000-01-31T00:00:00\",\n \"DokumentaVersija\": \"est dolor in non dolore\",\n \"DokumentaVeids\": \"minim amet\",\n \"PeriodsNo\": \"2000-01-31T00:00:00\",\n \"PeriodsLidz\": \"2000-01-31T00:00:00\",\n \"Papildinformacija\": \"cillum mollit occaecat eiusmod\",\n \"StatussId\": -94109410,\n \"Statuss\": \"laborum incididunt consectetur\",\n \"IrBridinajumi\": false,\n \"VarIesniegt\": false,\n \"VarDzest\": false,\n \"IrSanemtasAtbildes\": false,\n \"Arhivets\": true\n }\n]"
},
{
"name": "Lietotājs nav autentificēts.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc"
],
"query": [
{
"key": "id",
"value": "25210683"
},
{
"key": "dokumentaVeidsKods",
"value": "nisi cillum sed"
},
{
"key": "statussId",
"value": "25210683"
},
{
"key": "izveidotsNo",
"value": "nisi cillum sed"
},
{
"key": "izveidotsLidz",
"value": "nisi cillum sed"
},
{
"key": "iesniegtsNo",
"value": "nisi cillum sed"
},
{
"key": "iesniegtsLidz",
"value": "nisi cillum sed"
},
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
},
{
"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/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc"
],
"query": [
{
"key": "id",
"value": "25210683"
},
{
"key": "dokumentaVeidsKods",
"value": "nisi cillum sed"
},
{
"key": "statussId",
"value": "25210683"
},
{
"key": "izveidotsNo",
"value": "nisi cillum sed"
},
{
"key": "izveidotsLidz",
"value": "nisi cillum sed"
},
{
"key": "iesniegtsNo",
"value": "nisi cillum sed"
},
{
"key": "iesniegtsLidz",
"value": "nisi cillum sed"
},
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
},
{
"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/doc?id=25210683&dokumentaVeidsKods=nisi cillum sed&statussId=25210683&izveidotsNo=nisi cillum sed&izveidotsLidz=nisi cillum sed&iesniegtsNo=nisi cillum sed&iesniegtsLidz=nisi cillum sed&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"doc"
],
"query": [
{
"key": "id",
"value": "25210683"
},
{
"key": "dokumentaVeidsKods",
"value": "nisi cillum sed"
},
{
"key": "statussId",
"value": "25210683"
},
{
"key": "izveidotsNo",
"value": "nisi cillum sed"
},
{
"key": "izveidotsLidz",
"value": "nisi cillum sed"
},
{
"key": "iesniegtsNo",
"value": "nisi cillum sed"
},
{
"key": "iesniegtsLidz",
"value": "nisi cillum sed"
},
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
},
{
"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": ""
}
]
}