Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Unicode C++ Web API Examples

Primary Categories

ABN AMRO
AWS Translate
Activix CRM
Adyen
Amazon MWS
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bitfinex v2 REST
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Jira
MYOB
Magento

MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
Rabobank
SOAP finkok.com
Shippo
Shopify
SimpleTexting
Square
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
WooCommerce
Xero
Yousign
_Miscellaneous_
eBay
effectconnect

 

 

 

(Unicode C++) DVLA Vehicle Enquiry Service

Demonstrates how to make a call to the DVLA Vehicle Enquiry API to get vehicle details of a specified vehicle. It uses the vehicle registration number as input to search and provide details of the vehicle.

For more information, see https://developer-portal.driver-vehicle-licensing.api.gov.uk/apis/vehicle-enquiry-service/vehicle-enquiry-service-description.html

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Win Mobile 5.0/Pocket PC 2003

Solaris C/C++

FreeBSD C/C++

OpenBSD C/C++

MinGW C/C++

#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
#include <CkStringBuilderW.h>

void ChilkatSample(void)
    {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttpW http;
    bool success;

    // Implements the following CURL command:

    // curl -X POST https://driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1/vehicles \
    //   -H "x-api-key: supplied API key" \
    //   -H "Accept: application/json" \
    //   -d '{"registrationNumber": "ABC1234"}'

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    // Use this online tool to generate code from sample JSON:
    // Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "registrationNumber": "ABC1234"
    // }

    CkJsonObjectW json;
    json.UpdateString(L"registrationNumber",L"ABC1234");

    http.SetRequestHeader(L"Accept",L"application/json");
    http.SetRequestHeader(L"x-api-key",L"supplied API key");

    CkHttpResponseW *resp = http.PostJson3(L"https://driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1/vehicles",L"application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkStringBuilderW sbResponseBody;
    resp->GetBodySb(sbResponseBody);
    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = resp->get_StatusCode();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",resp->header());
        wprintf(L"Failed.\n");
        delete resp;
        return;
    }

    delete resp;

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "artEndDate": "2025-02-28",
    //   "co2Emissions": 135,
    //   "colour": "BLUE",
    //   "engineCapacity": 2494,
    //   "fuelType": "PETROL",
    //   "make": "ROVER",
    //   "markedForExport": false,
    //   "monthOfFirstRegistration": "2004-12",
    //   "motStatus": "No details held by DVLA",
    //   "registrationNumber": "ABC1234",
    //   "revenueWeight": 1640,
    //   "taxDueDate": "2007-01-01",
    //   "taxStatus": "Untaxed",
    //   "typeApproval": "N1",
    //   "wheelplan": "NON STANDARD",
    //   "yearOfManufacture": 2004,
    //   "euroStatus": "EURO 6 AD",
    //   "realDrivingEmissions": "1",
    //   "dateOfLastV5CIssued": "2016-12-25"
    // }

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    // See this example explaining how this memory should be used: const char * functions.

    const wchar_t *artEndDate = jResp.stringOf(L"artEndDate");
    int co2Emissions = jResp.IntOf(L"co2Emissions");
    const wchar_t *colour = jResp.stringOf(L"colour");
    int engineCapacity = jResp.IntOf(L"engineCapacity");
    const wchar_t *fuelType = jResp.stringOf(L"fuelType");
    const wchar_t *make = jResp.stringOf(L"make");
    bool markedForExport = jResp.BoolOf(L"markedForExport");
    const wchar_t *monthOfFirstRegistration = jResp.stringOf(L"monthOfFirstRegistration");
    const wchar_t *motStatus = jResp.stringOf(L"motStatus");
    const wchar_t *registrationNumber = jResp.stringOf(L"registrationNumber");
    int revenueWeight = jResp.IntOf(L"revenueWeight");
    const wchar_t *taxDueDate = jResp.stringOf(L"taxDueDate");
    const wchar_t *taxStatus = jResp.stringOf(L"taxStatus");
    const wchar_t *typeApproval = jResp.stringOf(L"typeApproval");
    const wchar_t *wheelplan = jResp.stringOf(L"wheelplan");
    int yearOfManufacture = jResp.IntOf(L"yearOfManufacture");
    const wchar_t *euroStatus = jResp.stringOf(L"euroStatus");
    const wchar_t *realDrivingEmissions = jResp.stringOf(L"realDrivingEmissions");
    const wchar_t *dateOfLastV5CIssued = jResp.stringOf(L"dateOfLastV5CIssued");
    }

 

© 2000-2020 Chilkat Software, Inc. All Rights Reserved.