SQL Server / EDS API / Pārskats par taksometru datu saņemšanu tiešsaistē.
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, 'parSevi', 'true'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'parvadatajaRegNr', 'est i'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'autovaditajaPersonasKods', 'consectet'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'transportlidzeklaNr', 'ut su'
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/reports/taxicarriages', @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)
-- {
-- "Parvadajumi": [
-- {
-- "ParvadatajaRegNr": "sunt sit",
-- "AutovaditajaPersonasKods": "quis consectetur D",
-- "TransportlidzeklaNr": "anim eu tempor",
-- "SakumaLaiks": "2000-01-31T00:00:00",
-- "BeiguLaiks": "2000-01-31T00:00:00",
-- "Attalums": -56070425.264373556,
-- "BrauksanasMaksa": -9970289.412923485,
-- "NorekinuVeids": "paymentCard",
-- "NorekinuVeidsTeksts": "dolor aliqua",
-- "SasijasNumurs": "repre",
-- "AbsolutaSummatoraStavoklis": -13456102.902620822,
-- "Komisija": 20507354.215314552,
-- "Izveidots": "2000-01-31T00:00:00"
-- },
-- {
-- "ParvadatajaRegNr": "dolor",
-- "AutovaditajaPersonasKods": "dolor do tempor molli",
-- "TransportlidzeklaNr": "do eu id veniam cupidatat",
-- "SakumaLaiks": "2000-01-31T00:00:00",
-- "BeiguLaiks": "2000-01-31T00:00:00",
-- "Attalums": 21856677.822087795,
-- "BrauksanasMaksa": -65166643.49096808,
-- "NorekinuVeids": "giftCard",
-- "NorekinuVeidsTeksts": "co",
-- "SasijasNumurs": "sint fugiat ea",
-- "AbsolutaSummatoraStavoklis": -73926198.93205424,
-- "Komisija": -8627515.159022048,
-- "Izveidots": "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 @ParvadatajaRegNr nvarchar(4000)
DECLARE @AutovaditajaPersonasKods nvarchar(4000)
DECLARE @TransportlidzeklaNr nvarchar(4000)
DECLARE @SakumaLaiks nvarchar(4000)
DECLARE @BeiguLaiks nvarchar(4000)
DECLARE @Attalums nvarchar(4000)
DECLARE @BrauksanasMaksa nvarchar(4000)
DECLARE @NorekinuVeids nvarchar(4000)
DECLARE @NorekinuVeidsTeksts nvarchar(4000)
DECLARE @SasijasNumurs nvarchar(4000)
DECLARE @AbsolutaSummatoraStavoklis nvarchar(4000)
DECLARE @Komisija nvarchar(4000)
DECLARE @Izveidots nvarchar(4000)
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'Parvadajumi'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @ParvadatajaRegNr OUT, 'Parvadajumi[i].ParvadatajaRegNr'
EXEC sp_OAMethod @jResp, 'StringOf', @AutovaditajaPersonasKods OUT, 'Parvadajumi[i].AutovaditajaPersonasKods'
EXEC sp_OAMethod @jResp, 'StringOf', @TransportlidzeklaNr OUT, 'Parvadajumi[i].TransportlidzeklaNr'
EXEC sp_OAMethod @jResp, 'StringOf', @SakumaLaiks OUT, 'Parvadajumi[i].SakumaLaiks'
EXEC sp_OAMethod @jResp, 'StringOf', @BeiguLaiks OUT, 'Parvadajumi[i].BeiguLaiks'
EXEC sp_OAMethod @jResp, 'StringOf', @Attalums OUT, 'Parvadajumi[i].Attalums'
EXEC sp_OAMethod @jResp, 'StringOf', @BrauksanasMaksa OUT, 'Parvadajumi[i].BrauksanasMaksa'
EXEC sp_OAMethod @jResp, 'StringOf', @NorekinuVeids OUT, 'Parvadajumi[i].NorekinuVeids'
EXEC sp_OAMethod @jResp, 'StringOf', @NorekinuVeidsTeksts OUT, 'Parvadajumi[i].NorekinuVeidsTeksts'
EXEC sp_OAMethod @jResp, 'StringOf', @SasijasNumurs OUT, 'Parvadajumi[i].SasijasNumurs'
EXEC sp_OAMethod @jResp, 'StringOf', @AbsolutaSummatoraStavoklis OUT, 'Parvadajumi[i].AbsolutaSummatoraStavoklis'
EXEC sp_OAMethod @jResp, 'StringOf', @Komisija OUT, 'Parvadajumi[i].Komisija'
EXEC sp_OAMethod @jResp, 'StringOf', @Izveidots OUT, 'Parvadajumi[i].Izveidots'
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 "parSevi=true"
-d "parvadatajaRegNr=est%20i"
-d "autovaditajaPersonasKods=consectet"
-d "transportlidzeklaNr=ut%20su"
-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/reports/taxicarriages
Postman Collection Item JSON
{
"name": "Pārskats par taksometru datu saņemšanu tiešsaistē.",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"taxicarriages"
],
"query": [
{
"key": "parSevi",
"value": "true",
"description": "Vai atlasīt nodokļu maksātāja vārdā saņemto informāciju."
},
{
"key": "parvadatajaRegNr",
"value": "est i",
"description": "Pārvadātāja reģistrācijas numurs komercreģistrā."
},
{
"key": "autovaditajaPersonasKods",
"value": "consectet",
"description": "Autovadītāja personas kods."
},
{
"key": "transportlidzeklaNr",
"value": "ut su",
"description": "Autotransporta līdzekļa valsts reģistrācijas numurs."
},
{
"key": "periodsNo",
"value": "nisi cillum sed",
"description": "(Required) Periods no."
},
{
"key": "periodsLidz",
"value": "nisi cillum sed",
"description": "(Required) Periods līdz."
},
{
"key": "izlaistIerakstus",
"value": "25210683",
"description": "(Required) No rezultāta izlaižamo ierakstu skaits."
},
{
"key": "atgrieztIerakstus",
"value": "25210683",
"description": "(Required) Atgriežamo ierakstu skaits."
}
]
}
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"taxicarriages"
],
"query": [
{
"key": "parSevi",
"value": "true"
},
{
"key": "parvadatajaRegNr",
"value": "est i"
},
{
"key": "autovaditajaPersonasKods",
"value": "consectet"
},
{
"key": "transportlidzeklaNr",
"value": "ut su"
},
{
"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 \"Parvadajumi\": [\n {\n \"ParvadatajaRegNr\": \"sunt sit\",\n \"AutovaditajaPersonasKods\": \"quis consectetur D\",\n \"TransportlidzeklaNr\": \"anim eu tempor\",\n \"SakumaLaiks\": \"2000-01-31T00:00:00\",\n \"BeiguLaiks\": \"2000-01-31T00:00:00\",\n \"Attalums\": -56070425.264373556,\n \"BrauksanasMaksa\": -9970289.412923485,\n \"NorekinuVeids\": \"paymentCard\",\n \"NorekinuVeidsTeksts\": \"dolor aliqua\",\n \"SasijasNumurs\": \"repre\",\n \"AbsolutaSummatoraStavoklis\": -13456102.902620822,\n \"Komisija\": 20507354.215314552,\n \"Izveidots\": \"2000-01-31T00:00:00\"\n },\n {\n \"ParvadatajaRegNr\": \"dolor\",\n \"AutovaditajaPersonasKods\": \"dolor do tempor molli\",\n \"TransportlidzeklaNr\": \"do eu id veniam cupidatat\",\n \"SakumaLaiks\": \"2000-01-31T00:00:00\",\n \"BeiguLaiks\": \"2000-01-31T00:00:00\",\n \"Attalums\": 21856677.822087795,\n \"BrauksanasMaksa\": -65166643.49096808,\n \"NorekinuVeids\": \"giftCard\",\n \"NorekinuVeidsTeksts\": \"co\",\n \"SasijasNumurs\": \"sint fugiat ea\",\n \"AbsolutaSummatoraStavoklis\": -73926198.93205424,\n \"Komisija\": -8627515.159022048,\n \"Izveidots\": \"2000-01-31T00:00:00\"\n }\n ]\n}"
},
{
"name": "Lietotājs nav autentificēts.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"taxicarriages"
],
"query": [
{
"key": "parSevi",
"value": "true"
},
{
"key": "parvadatajaRegNr",
"value": "est i"
},
{
"key": "autovaditajaPersonasKods",
"value": "consectet"
},
{
"key": "transportlidzeklaNr",
"value": "ut su"
},
{
"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/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"taxicarriages"
],
"query": [
{
"key": "parSevi",
"value": "true"
},
{
"key": "parvadatajaRegNr",
"value": "est i"
},
{
"key": "autovaditajaPersonasKods",
"value": "consectet"
},
{
"key": "transportlidzeklaNr",
"value": "ut su"
},
{
"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/reports/taxicarriages?parSevi=true&parvadatajaRegNr=est i&autovaditajaPersonasKods=consectet&transportlidzeklaNr=ut su&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"reports",
"taxicarriages"
],
"query": [
{
"key": "parSevi",
"value": "true"
},
{
"key": "parvadatajaRegNr",
"value": "est i"
},
{
"key": "autovaditajaPersonasKods",
"value": "consectet"
},
{
"key": "transportlidzeklaNr",
"value": "ut su"
},
{
"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": ""
}
]
}