SQL Server / EDS API / Apstiprinātās rezidenta apliecības - iesniegumi nodokļu atvieglojumu piemērošanai.
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, 'periodsNo', 'nisi cillum sed'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'periodsLidz', 'nisi cillum sed'
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/reports/certificatesofresidency', @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 @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 @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 @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "RezidentaApliecibas": [
-- {
-- "Nosaukums": "sunt reprehenderit cillum Excepteur",
-- "IenakumuVeids": "laboris tempor nisi reprehenderit",
-- "RezidencesValsts": "aliqua deserunt labore laborum do",
-- "DatumsNo": "2000-01-31T00:00:00",
-- "DatumsLidz": "2000-01-31T00:00:00"
-- },
-- {
-- "Nosaukums": "eni",
-- "IenakumuVeids": "cupid",
-- "RezidencesValsts": "non quis adipisicing",
-- "DatumsNo": "2000-01-31T00:00:00",
-- "DatumsLidz": "2000-01-31T00:00:00"
-- }
-- ]
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @Nosaukums nvarchar(4000)
DECLARE @IenakumuVeids nvarchar(4000)
DECLARE @RezidencesValsts nvarchar(4000)
DECLARE @DatumsNo nvarchar(4000)
DECLARE @DatumsLidz nvarchar(4000)
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'RezidentaApliecibas'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @Nosaukums OUT, 'RezidentaApliecibas[i].Nosaukums'
EXEC sp_OAMethod @jResp, 'StringOf', @IenakumuVeids OUT, 'RezidentaApliecibas[i].IenakumuVeids'
EXEC sp_OAMethod @jResp, 'StringOf', @RezidencesValsts OUT, 'RezidentaApliecibas[i].RezidencesValsts'
EXEC sp_OAMethod @jResp, 'StringOf', @DatumsNo OUT, 'RezidentaApliecibas[i].DatumsNo'
EXEC sp_OAMethod @jResp, 'StringOf', @DatumsLidz OUT, 'RezidentaApliecibas[i].DatumsLidz'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -G -d "periodsNo=nisi%20cillum%20sed"
-d "periodsLidz=nisi%20cillum%20sed"
-H "Accept: application/json"
https://eds.vid.gov.lv/api/reports/certificatesofresidency
Postman Collection Item JSON
{
"name": "Apstiprinātās rezidenta apliecības - iesniegumi nodokļu atvieglojumu piemērošanai.",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/reports/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed",
"description": "(Required) Periods no."
},
{
"key": "periodsLidz",
"value": "nisi cillum sed",
"description": "(Required) Periods līdz."
}
]
}
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/reports/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"RezidentaApliecibas\": [\n {\n \"Nosaukums\": \"sunt reprehenderit cillum Excepteur\",\n \"IenakumuVeids\": \"laboris tempor nisi reprehenderit\",\n \"RezidencesValsts\": \"aliqua deserunt labore laborum do\",\n \"DatumsNo\": \"2000-01-31T00:00:00\",\n \"DatumsLidz\": \"2000-01-31T00:00:00\"\n },\n {\n \"Nosaukums\": \"eni\",\n \"IenakumuVeids\": \"cupid\",\n \"RezidencesValsts\": \"non quis adipisicing\",\n \"DatumsNo\": \"2000-01-31T00:00:00\",\n \"DatumsLidz\": \"2000-01-31T00:00:00\"\n }\n ]\n}"
},
{
"name": "Lietotājs nav autentificēts.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/reports/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
}
]
}
},
"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/reports/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
}
]
}
},
"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/reports/certificatesofresidency?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"certificatesofresidency"
],
"query": [
{
"key": "periodsNo",
"value": "nisi cillum sed"
},
{
"key": "periodsLidz",
"value": "nisi cillum sed"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}