Chilkat Online Tools

SQL Server / EDS API / Budžeta maksājumu nomaksas stāvoklis.

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, 'datums', '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/budgetpaymentstatus', @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)

    -- {
    --   "ParadsParmaksa": -50447879.235281065,
    --   "NakotnesMaksajumi": -81582806.04053694,
    --   "Nodokli": [
    --     {
    --       "Veids": "an",
    --       "ParadsParmaksa": 80790125.40502116,
    --       "Pamatsumma": 65859694.17103809,
    --       "NokavejumaNauda": 98883203.72957286,
    --       "SodaNauda": 14963756.038831204,
    --       "SummaNeattiecinata": 63137634.62906712
    --     },
    --     {
    --       "Veids": "do dolor ad Ut",
    --       "ParadsParmaksa": 43237471.160656095,
    --       "Pamatsumma": -57340675.158834875,
    --       "NokavejumaNauda": -28474260.06191136,
    --       "SodaNauda": 45114141.83812463,
    --       "SummaNeattiecinata": 31850879.05370581
    --     }
    --   ],
    --   "NodokliKopa": {
    --     "Veids": "laborum sit",
    --     "ParadsParmaksa": 89408877.17641428,
    --     "Pamatsumma": 54833696.214086235,
    --     "NokavejumaNauda": 30588882.734033525,
    --     "SodaNauda": 30389453.734095544,
    --     "SummaNeattiecinata": -32969116.936048113
    --   },
    --   "Saistibas": [
    --     {
    --       "Veids": "occaecat aliquip",
    --       "Dokuments": "mollit veniam",
    --       "PeriodsNo": "2000-01-31T00:00:00",
    --       "PeriodsLidz": "2000-01-31T00:00:00",
    --       "AprekinataSumma": -52433956.95264397,
    --       "ParadsParmaksa": -2135445.6856855154
    --     },
    --     {
    --       "Veids": "fugiat occaecat commodo adipisicing",
    --       "Dokuments": "repre",
    --       "PeriodsNo": "2000-01-31T00:00:00",
    --       "PeriodsLidz": "2000-01-31T00:00:00",
    --       "AprekinataSumma": 42174769.96948132,
    --       "ParadsParmaksa": 82409418.55805573
    --     }
    --   ],
    --   "SummaNeattiecinata": 16640276.060317397
    -- }

    -- Sample code for parsing the JSON response...
    -- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    DECLARE @Dokuments nvarchar(4000)

    DECLARE @PeriodsNo nvarchar(4000)

    DECLARE @PeriodsLidz nvarchar(4000)

    DECLARE @AprekinataSumma nvarchar(4000)

    DECLARE @ParadsParmaksa nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ParadsParmaksa OUT, 'ParadsParmaksa'
    DECLARE @NakotnesMaksajumi nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @NakotnesMaksajumi OUT, 'NakotnesMaksajumi'
    DECLARE @Veids nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Veids OUT, 'NodokliKopa.Veids'
    DECLARE @NodokliKopaParadsParmaksa nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @NodokliKopaParadsParmaksa OUT, 'NodokliKopa.ParadsParmaksa'
    DECLARE @Pamatsumma nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Pamatsumma OUT, 'NodokliKopa.Pamatsumma'
    DECLARE @NokavejumaNauda nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @NokavejumaNauda OUT, 'NodokliKopa.NokavejumaNauda'
    DECLARE @SodaNauda nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @SodaNauda OUT, 'NodokliKopa.SodaNauda'
    DECLARE @SummaNeattiecinata nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @SummaNeattiecinata OUT, 'NodokliKopa.SummaNeattiecinata'
    EXEC sp_OAMethod @jResp, 'StringOf', @SummaNeattiecinata OUT, 'SummaNeattiecinata'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'Nodokli'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @Veids OUT, 'Nodokli[i].Veids'
        EXEC sp_OAMethod @jResp, 'StringOf', @ParadsParmaksa OUT, 'Nodokli[i].ParadsParmaksa'
        EXEC sp_OAMethod @jResp, 'StringOf', @Pamatsumma OUT, 'Nodokli[i].Pamatsumma'
        EXEC sp_OAMethod @jResp, 'StringOf', @NokavejumaNauda OUT, 'Nodokli[i].NokavejumaNauda'
        EXEC sp_OAMethod @jResp, 'StringOf', @SodaNauda OUT, 'Nodokli[i].SodaNauda'
        EXEC sp_OAMethod @jResp, 'StringOf', @SummaNeattiecinata OUT, 'Nodokli[i].SummaNeattiecinata'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'Saistibas'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @Veids OUT, 'Saistibas[i].Veids'
        EXEC sp_OAMethod @jResp, 'StringOf', @Dokuments OUT, 'Saistibas[i].Dokuments'
        EXEC sp_OAMethod @jResp, 'StringOf', @PeriodsNo OUT, 'Saistibas[i].PeriodsNo'
        EXEC sp_OAMethod @jResp, 'StringOf', @PeriodsLidz OUT, 'Saistibas[i].PeriodsLidz'
        EXEC sp_OAMethod @jResp, 'StringOf', @AprekinataSumma OUT, 'Saistibas[i].AprekinataSumma'
        EXEC sp_OAMethod @jResp, 'StringOf', @ParadsParmaksa OUT, 'Saistibas[i].ParadsParmaksa'
        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 "datums=nisi%20cillum%20sed"
	-H "Accept: application/json"
https://eds.vid.gov.lv/api/reports/budgetpaymentstatus

Postman Collection Item JSON

{
  "name": "Budžeta maksājumu nomaksas stāvoklis.",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/reports/budgetpaymentstatus?datums=nisi cillum sed",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "reports",
        "budgetpaymentstatus"
      ],
      "query": [
        {
          "key": "datums",
          "value": "nisi cillum sed",
          "description": "(Required) Pārskata datums."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/budgetpaymentstatus?datums=nisi cillum sed",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "budgetpaymentstatus"
          ],
          "query": [
            {
              "key": "datums",
              "value": "nisi cillum sed"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"ParadsParmaksa\": -50447879.235281065,\n  \"NakotnesMaksajumi\": -81582806.04053694,\n  \"Nodokli\": [\n    {\n      \"Veids\": \"an\",\n      \"ParadsParmaksa\": 80790125.40502116,\n      \"Pamatsumma\": 65859694.17103809,\n      \"NokavejumaNauda\": 98883203.72957286,\n      \"SodaNauda\": 14963756.038831204,\n      \"SummaNeattiecinata\": 63137634.62906712\n    },\n    {\n      \"Veids\": \"do dolor ad Ut\",\n      \"ParadsParmaksa\": 43237471.160656095,\n      \"Pamatsumma\": -57340675.158834875,\n      \"NokavejumaNauda\": -28474260.06191136,\n      \"SodaNauda\": 45114141.83812463,\n      \"SummaNeattiecinata\": 31850879.05370581\n    }\n  ],\n  \"NodokliKopa\": {\n    \"Veids\": \"laborum sit\",\n    \"ParadsParmaksa\": 89408877.17641428,\n    \"Pamatsumma\": 54833696.214086235,\n    \"NokavejumaNauda\": 30588882.734033525,\n    \"SodaNauda\": 30389453.734095544,\n    \"SummaNeattiecinata\": -32969116.936048113\n  },\n  \"Saistibas\": [\n    {\n      \"Veids\": \"occaecat aliquip\",\n      \"Dokuments\": \"mollit veniam\",\n      \"PeriodsNo\": \"2000-01-31T00:00:00\",\n      \"PeriodsLidz\": \"2000-01-31T00:00:00\",\n      \"AprekinataSumma\": -52433956.95264397,\n      \"ParadsParmaksa\": -2135445.6856855154\n    },\n    {\n      \"Veids\": \"fugiat occaecat commodo adipisicing\",\n      \"Dokuments\": \"repre\",\n      \"PeriodsNo\": \"2000-01-31T00:00:00\",\n      \"PeriodsLidz\": \"2000-01-31T00:00:00\",\n      \"AprekinataSumma\": 42174769.96948132,\n      \"ParadsParmaksa\": 82409418.55805573\n    }\n  ],\n  \"SummaNeattiecinata\": 16640276.060317397\n}"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/budgetpaymentstatus?datums=nisi cillum sed",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "budgetpaymentstatus"
          ],
          "query": [
            {
              "key": "datums",
              "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/budgetpaymentstatus?datums=nisi cillum sed",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "budgetpaymentstatus"
          ],
          "query": [
            {
              "key": "datums",
              "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/budgetpaymentstatus?datums=nisi cillum sed",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "budgetpaymentstatus"
          ],
          "query": [
            {
              "key": "datums",
              "value": "nisi cillum sed"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}