Chilkat Online Tools

SQL Server / EDS API / Nodokļu maksātājam iesniegto algas nodokļu grāmatiņu dati.

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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @queryParams int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'tikaiIzmainas', 'true'
    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, 'UpdateString', @success OUT, 'iesniedzejs', 'est i'
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'pmnmIzmainas', 25210683
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'neattelotAtvieglojumus', 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/taxbooks', @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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.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)

    -- {
    --   "Gramatinas": [
    --     {
    --       "PersonasKods": "incididunt aute laborum sed",
    --       "VardsUzvards": "reprehenderi",
    --       "Numurs": "eiusmod sed ut tempor nulla",
    --       "IzdosanasDatums": "2000-01-31T00:00:00",
    --       "DatumsNo": "2000-01-31T00:00:00",
    --       "IzmainuDatums": "2000-01-31T00:00:00",
    --       "DatumsLidz": "2000-01-31T00:00:00",
    --       "Apgadajamie": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ],
    --       "Pensijas": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ],
    --       "PapilduAtvieglojumi": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ],
    --       "IinLikmes": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ],
    --       "PrognozetaisMinimums": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ]
    --     },
    --     {
    --       "PersonasKods": "qui cillum fugiat",
    --       "VardsUzvards": "reprehenderit minim consectetur consequat ea",
    --       "Numurs": "ut labore mollit",
    --       "IzdosanasDatums": "2000-01-31T00:00:00",
    --       "DatumsNo": "2000-01-31T00:00:00",
    --       "IzmainuDatums": "2000-01-31T00:00:00",
    --       "DatumsLidz": "2000-01-31T00:00:00",
    --       "Apgadajamie": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ],
    --       "Pensijas": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ],
    --       "PapilduAtvieglojumi": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ],
    --       "IinLikmes": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ],
    --       "PrognozetaisMinimums": [
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       ]
    --     }
    --   ]
    -- }

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

    DECLARE @PersonasKods nvarchar(4000)

    DECLARE @VardsUzvards nvarchar(4000)

    DECLARE @Numurs nvarchar(4000)

    DECLARE @IzdosanasDatums nvarchar(4000)

    DECLARE @DatumsNo nvarchar(4000)

    DECLARE @IzmainuDatums nvarchar(4000)

    DECLARE @DatumsLidz nvarchar(4000)

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @value nvarchar(4000)

    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'Gramatinas'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @PersonasKods OUT, 'Gramatinas[i].PersonasKods'
        EXEC sp_OAMethod @jResp, 'StringOf', @VardsUzvards OUT, 'Gramatinas[i].VardsUzvards'
        EXEC sp_OAMethod @jResp, 'StringOf', @Numurs OUT, 'Gramatinas[i].Numurs'
        EXEC sp_OAMethod @jResp, 'StringOf', @IzdosanasDatums OUT, 'Gramatinas[i].IzdosanasDatums'
        EXEC sp_OAMethod @jResp, 'StringOf', @DatumsNo OUT, 'Gramatinas[i].DatumsNo'
        EXEC sp_OAMethod @jResp, 'StringOf', @IzmainuDatums OUT, 'Gramatinas[i].IzmainuDatums'
        EXEC sp_OAMethod @jResp, 'StringOf', @DatumsLidz OUT, 'Gramatinas[i].DatumsLidz'
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Gramatinas[i].Apgadajamie'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'Gramatinas[i].Apgadajamie[j].value'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Gramatinas[i].Pensijas'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'Gramatinas[i].Pensijas[j].value'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Gramatinas[i].PapilduAtvieglojumi'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'Gramatinas[i].PapilduAtvieglojumi[j].value'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Gramatinas[i].IinLikmes'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'Gramatinas[i].IinLikmes[j].value'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Gramatinas[i].PrognozetaisMinimums'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'Gramatinas[i].PrognozetaisMinimums[j].value'
            SELECT @j = @j + 1
          END
        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 "tikaiIzmainas=true"
	-d "periodsNo=nisi%20cillum%20sed"
	-d "periodsLidz=nisi%20cillum%20sed"
	-d "iesniedzejs=est%20i"
	-d "pmnmIzmainas=25210683"
	-d "neattelotAtvieglojumus=25210683"
	-H "Accept: application/json"
https://eds.vid.gov.lv/api/reports/taxbooks

Postman Collection Item JSON

{
  "name": "Nodokļu maksātājam iesniegto algas nodokļu grāmatiņu dati.",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/reports/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "reports",
        "taxbooks"
      ],
      "query": [
        {
          "key": "tikaiIzmainas",
          "value": "true",
          "description": "Atlasīt tikai tās grāmatiņas kurās veiktas izmaiņas."
        },
        {
          "key": "periodsNo",
          "value": "nisi cillum sed",
          "description": "(Required) Pārskata perioda sākuma datums."
        },
        {
          "key": "periodsLidz",
          "value": "nisi cillum sed",
          "description": "ārskata perioda beigu datums."
        },
        {
          "key": "iesniedzejs",
          "value": "est i",
          "description": "Grāmatiņas iesniedzēja personas kods."
        },
        {
          "key": "pmnmIzmainas",
          "value": "25210683",
          "description": "Iekļaut nodokļu maksātājus, kuriem:\r\n0 - mainījušies algas nodokļa grāmatiņas dati, izņemot prognozēto mēneša neapliekamo minimumu;\r\n1 - mainījušies algas nodokļa grāmatiņas dati, tai skaitā arī prognozētais mēneša neapliekamais minimums;\r\n2 - mainījies tikai prognozētais mēneša neapliekamais minimums."
        },
        {
          "key": "neattelotAtvieglojumus",
          "value": "25210683",
          "description": "Neattēlot nodokļa atvieglojumus, kuri bija spēkā pirms pārskatā norādītā perioda."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxbooks"
          ],
          "query": [
            {
              "key": "tikaiIzmainas",
              "value": "true"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniedzejs",
              "value": "est i"
            },
            {
              "key": "pmnmIzmainas",
              "value": "25210683"
            },
            {
              "key": "neattelotAtvieglojumus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"Gramatinas\": [\n    {\n      \"PersonasKods\": \"incididunt aute laborum sed\",\n      \"VardsUzvards\": \"reprehenderi\",\n      \"Numurs\": \"eiusmod sed ut tempor nulla\",\n      \"IzdosanasDatums\": \"2000-01-31T00:00:00\",\n      \"DatumsNo\": \"2000-01-31T00:00:00\",\n      \"IzmainuDatums\": \"2000-01-31T00:00:00\",\n      \"DatumsLidz\": \"2000-01-31T00:00:00\",\n      \"Apgadajamie\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"Pensijas\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"PapilduAtvieglojumi\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"IinLikmes\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"PrognozetaisMinimums\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ]\n    },\n    {\n      \"PersonasKods\": \"qui cillum fugiat\",\n      \"VardsUzvards\": \"reprehenderit minim consectetur consequat ea\",\n      \"Numurs\": \"ut labore mollit\",\n      \"IzdosanasDatums\": \"2000-01-31T00:00:00\",\n      \"DatumsNo\": \"2000-01-31T00:00:00\",\n      \"IzmainuDatums\": \"2000-01-31T00:00:00\",\n      \"DatumsLidz\": \"2000-01-31T00:00:00\",\n      \"Apgadajamie\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"Pensijas\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"PapilduAtvieglojumi\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"IinLikmes\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"PrognozetaisMinimums\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ]\n    }\n  ]\n}"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxbooks"
          ],
          "query": [
            {
              "key": "tikaiIzmainas",
              "value": "true"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniedzejs",
              "value": "est i"
            },
            {
              "key": "pmnmIzmainas",
              "value": "25210683"
            },
            {
              "key": "neattelotAtvieglojumus",
              "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/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxbooks"
          ],
          "query": [
            {
              "key": "tikaiIzmainas",
              "value": "true"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniedzejs",
              "value": "est i"
            },
            {
              "key": "pmnmIzmainas",
              "value": "25210683"
            },
            {
              "key": "neattelotAtvieglojumus",
              "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/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxbooks"
          ],
          "query": [
            {
              "key": "tikaiIzmainas",
              "value": "true"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniedzejs",
              "value": "est i"
            },
            {
              "key": "pmnmIzmainas",
              "value": "25210683"
            },
            {
              "key": "neattelotAtvieglojumus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}