Skip to main content
NHVR Portal API - find* methods - C#

For findCustomer, findPartner, findProvider API controller methods

Updated over 2 years ago

To more easily use JSON data in C#, you will need to install the JSON.Net library from https://www.newtonsoft.com/json.

All API calls require the endpoint URL and a set of headers. Some API calls will also require parameters (GET or DELETE requests) or data (POST or PUT) requests.

Every findCustomer, findPartner, or findProvider API call should include the following headers:

Header

Value

Note

Content-Type

'application/json'

All calls are made using JSON data structures

Ocp-Apim-Subscription-Key

Your subscription key for the NHVR Portal API

The subscription key uniquely identifies you to the NHVR Portal API

The find* endpoint uses the GET method and has three parameters:

  1. <Controller Entity Name>View<Account Type>Filter

  2. view

  3. viewAction

Filter

The filter parameter allows for paginating results, ordering results and filtering using a where clause. The following sub parameters are available:

Sub-parameter

Default value

Note

limit

10

The maximum number of records returned by the method.

The allowed range for this parameter is 1 to 500.

skip

0

The number of records to skip in the record set. Use to paginate records.

order

The order clause to for sorting records.

where

The where clause for filtering records.

The filter parameter name consists of the API controller entity name and the account type and can be found in the API definitions found in the NHVR Developer Portal.

In this article we will use the VehicleRegistrationController.findCustomer controller method available from the NHVR Portal - Vehicle Service.

The filter parameter name for the VehicleRegistrationController.findCustomer controller method is: VehicleRegistrationViewCustomerFilter

Currently the 'where' sub-parameter must be supplied even if not required. If not required then set the 'where' sub-parameter to '{}'.

Limit

To control the number of records returned by the method set the limit to a value between 1 and 500.

https://api-public.nhvr.gov.au/vehicle/vehicleRegistrations-customer?VehicleRegistrationViewCustomerFilter={"limit": 500, "where": {}}

Skip

If the total records available exceeds the limit then use skip to control the number of records to skip as the starting point for the records returned.

https://api-public.nhvr.gov.au/vehicle/vehicleRegistrations-customer?VehicleRegistrationViewCustomerFilter={"limit": 500, "skip": 500, "where": {}}

Order

To sort the record set specify the field or fields to sort in array and use the sort type 'DESC' to sort the field in descending alphanumeric order or 'ASC' to sort the field in ascending alphanumeric order.

https://api-public.nhvr.gov.au/vehicle/vehicleRegistrations-customer?VehicleRegistrationViewCustomerFilter={"limit": 10, "skip": 0, "order": ["vehicleId DESC"], "where": {}}

Where

To filter the record set specify the field or fields to filter in an object using the key as the field and the value as the filter value.

https://api-public.nhvr.gov.au/vehicle/vehicleRegistrations-customer?VehicleRegistrationViewCustomerFilter={"limit": 10, "skip": 0, "order": ["vehicleId DESC"], "where": {"vehicleId": 1}}

C# example

using System;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Net.Http;
using System.Web;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace CSHttpClientSample
{

public class LoginResponse
{
public string token { get; set; }
public string refreshToken { get; set; }
}

static class Program
{
static void Main()
{
MainAsync();
Console.ReadLine();
}

static async void MainAsync()
{
var client = new HttpClient();
var subscriptionKey = "<subscription key>";
var findResult = await GetVehicleRegistrations(client, subscriptionKey);
Console.WriteLine(findResult);
}


static async Task<string> GetVehicleRegistrations(HttpClient client, string subscriptionKey)
{
var queryString = HttpUtility.ParseQueryString("VehicleRegistrationViewCustomerFilter={\"limit\": 10, \"skip\": 0, \"order\": [\"vehicleId DESC\"], \"where\": {\"vehicleId\": \"1\"}}");
var uri = "https://api-public.nhvr.gov.au/vehicle/vehicleRegistrations-customer?" + queryString;

// Headers
client.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

// Get
HttpResponseMessage response = await client.GetAsync(uri);

string jsonResponse = response.Content.ReadAsStringAsync().Result;
return jsonResponse;
}
}
}

Did this answer your question?