Chilkat Online Tools

Java / EDS API / Apstiprinātās rezidenta apliecības - iesniegumi nodokļu atvieglojumu piemērošanai.

Back to Collection Items

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();
    boolean success;

    CkJsonObject queryParams = new CkJsonObject();
    queryParams.UpdateString("periodsNo","nisi cillum sed");
    queryParams.UpdateString("periodsLidz","nisi cillum sed");

    http.SetRequestHeader("Accept","application/json");

    CkHttpResponse resp = http.QuickRequestParams("GET","https://eds.vid.gov.lv/api/reports/certificatesofresidency",queryParams);
    if (http.get_LastMethodSuccess() == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    resp.GetBodySb(sbResponseBody);

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    System.out.println("Response Body:");
    System.out.println(jResp.emit());

    int respStatusCode = resp.get_StatusCode();
    System.out.println("Response Status Code = " + respStatusCode);
    if (respStatusCode >= 400) {
        System.out.println("Response Header:");
        System.out.println(resp.header());
        System.out.println("Failed.");

        return;
        }

    // 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

    String Nosaukums;
    String IenakumuVeids;
    String RezidencesValsts;
    String DatumsNo;
    String DatumsLidz;

    int i = 0;
    int count_i = jResp.SizeOfArray("RezidentaApliecibas");
    while (i < count_i) {
        jResp.put_I(i);
        Nosaukums = jResp.stringOf("RezidentaApliecibas[i].Nosaukums");
        IenakumuVeids = jResp.stringOf("RezidentaApliecibas[i].IenakumuVeids");
        RezidencesValsts = jResp.stringOf("RezidentaApliecibas[i].RezidencesValsts");
        DatumsNo = jResp.stringOf("RezidentaApliecibas[i].DatumsNo");
        DatumsLidz = jResp.stringOf("RezidentaApliecibas[i].DatumsLidz");
        i = i+1;
        }
  }
}

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": ""
    }
  ]
}