Data Validation The Easy Way
Written by Ian Elliot   
Tuesday, 20 February 2018
Article Index
Data Validation The Easy Way
Using Post for Multi-Record Query

Checking data can be difficult, simply because of the need to keep cleaning the reference data. Who can afford the resources to do the job? The best solution for most of us is to use a cloud-based service and Melissa has now made it easy for you to try it out.

 

clouds

Melissa’s Developer Portal offers data verification services including Business Coder UK (firmographics), Global Address, Phone, and Email Verification, Global Express Entry, IP Location, and Personator (ID Verification).

 

I've used Melissa before in projects to verify clients' address details, but with the help of an off-the-shelf component - jQuery UI's Auto-complete widget. Now I need to do something more sophisticated and the good news is that all of the data cleaning services offered by Melissa have been made easier to use with the addition of a dashboard that constructs the necessary calls. This can be accessed from Melissa's new Developer Portal.

 

mellissaportal

 

In principle creating an app that accesses a web API is easy.You have to specify the input parameters, make a Get or a Post HTTP request and deal with the data you get back. The Melissa APIs support both a classic REST API and a JSON based request which is very easy to implement in any language with even basic JSON support but it is particularly easy if you use jQuery.

So which do you use - REST or JSON?

As far as I'm concerned JSON wins without much consideration of REST. This is partly due to the idea that the URL should indicate a location not an action, but it is also partly a reaction to coding data into the URL. If you are going to use REST then at least make it POST based so that the data isn't visible to the end user, even if the logic of REST suggests it should be a POST. 

For me the whole idea of REST is a wrong turning in the design of apps and is based on a misunderstanding. Keep the data in the body as a serialized object and use the URL to identify endpoints seems like a much better idea. 

So, as you can probably guess the rest of this article focuses on JSON. If you want to use REST then the documentation makes it easy and there are lots of examples.

If you are using the JSON API then the steps are always the same. Just fill the data structure JSON  and make the GET or POST HTTP call using the correct URL. From my earlier comments you can guess that I prefer POST because it hides the data from the end user but both are supported.

Easy in theory but there is still a lot to get right and if it doesn't work you have to navigate the error messages returned by the server. These are often fine when you know what you are doing, but even the best error messages can be a mystery when you are first starting. This is where the new dashboard approach used by the Melissa Developer Portal comes in.

Basically a dashboard lets you submit queries that it helps you construct and see the answer. It also provides boilerplate code in a range of languages that gets the same job done. OK. this isn't the final code that you are going to use. You are going to have to get the data into the JSON and you are going to have to get the data out of the response, but this is a matter of working with your own code and so much easier to get started with.

iplocate

Global IP Locator

Let's get started with a simple example. In this case simple is best because all of the APIs work in more or less the same way but require more data to be specified. The Global IP Locator takes an IP address and returns not just the location of the entity that the address is registered to but a surprising amount of additional data. As well as city and postal code you also get connection type and speed, latitude and longitude, domain name etc.

 

mellisa1

 

The documentation says that you can use it to:  

  • Verify that an IP address is valid
  • Associate a physical location with an IP address
  • Determine connection type and speed
  • Associate an ISP with an IP address.

The basic API use is fairly standard. First you fill a data structure:

InputDescription
Transmission Reference A unique string value identifying the request
Customer ID License String from Melissa
Record ID Unique ID if processing multiple records
IP Address IP Address to validate

 

Note you need a Customer ID for any of the APIs to work. You can get an ID from Melissa for a free trial by supplying your name, email and phone number.

The other input parameters are straightforward apart from a unique string value identifying the request. I don't know about you but generating a "unique" anything always sends me into a panic. In this case you don't have to panic because a sequential count will identify your request perfectly uniquely - unless you have multiple agents making requests when a prefix identifying each one solves the problem.

There is a similar table summarising the fields that are returns in a JSON response but this is easier to understand after you have seen the mechanism in action.

Log into the Developer Portal and select the Global IP Locator Product from the list at the left:

console1 

What you see initially is the basic documentation for the API which is where all of the information listed above is obtained from. This is easy to follow but select Console from the tab and you can put the theory into practice.

First select the HTTP operation you want to use. I opted for GET because it is slightly easier to get started with:

getput

 

Once you do this you will see sample code for the language of your choice - JavaScript, NodeJS,PHP or Ruby at the time of writing. I used JavaScript which makes use of my favourite library jQuery to perform the Ajax call.

All you have to do is fill in the blanks in the parameter section:

api1

Once you have filled in the details the results usually appear at once, but if you want to refresh the results click the View Results button: 

results

You can see the JSON data structure and you can look up the meaning of any fields that aren't perfectly clear. What is interesting is how much easier it is to understand the meaning of the fields when you can set them and see the result. There are no ambiguities - you can see what works.

 



Last Updated ( Saturday, 24 February 2018 )