SQL Server / EDS API / Amatpersonu 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, 'UpdateString', @success OUT, 'vardsUzvards', 'Lorem qui in'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'personasKods', 'est i'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'amats', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'datumsNoIntervalsNo', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'datumsNoIntervalsLidz', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'datumsLidzIntervalsNo', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'datumsLidzIntervalsLidz', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'ierednis', 'true'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'aizvieto', 'true'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'aktuals', 'true'
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/officials', @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)
-- [
-- {
-- "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
DECLARE @json int
DECLARE @VardsUzvards nvarchar(4000)
DECLARE @PersonasKods nvarchar(4000)
DECLARE @AmataKods nvarchar(4000)
DECLARE @AmataNosaukums nvarchar(4000)
DECLARE @DatumsNo nvarchar(4000)
DECLARE @DatumsLidz nvarchar(4000)
DECLARE @Ierednis int
DECLARE @Aizvieto 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, 'StringOf', @VardsUzvards OUT, 'VardsUzvards'
EXEC sp_OAMethod @json, 'StringOf', @PersonasKods OUT, 'PersonasKods'
EXEC sp_OAMethod @json, 'StringOf', @AmataKods OUT, 'AmataKods'
EXEC sp_OAMethod @json, 'StringOf', @AmataNosaukums OUT, 'AmataNosaukums'
EXEC sp_OAMethod @json, 'StringOf', @DatumsNo OUT, 'DatumsNo'
EXEC sp_OAMethod @json, 'StringOf', @DatumsLidz OUT, 'DatumsLidz'
EXEC sp_OAMethod @json, 'BoolOf', @Ierednis OUT, 'Ierednis'
EXEC sp_OAMethod @json, 'BoolOf', @Aizvieto OUT, 'Aizvieto'
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 "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": ""
}
]
}