Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Webservice validate UK EORI-numbers 1

Status
Not open for further replies.

Gerrit Broekhuis

Programmer
Aug 16, 2004
316
NL
Hi,

After Brexit EORI-numbers can no longer be validated by the EU validator. Therefore I want to use to validate EORI-numbers from the UK (GB...etc.).

I've already registered at GOV.UK, but I cannot find good examples or documentation to get started using VFP.

Has anyone perhaps already tried to check UK EORI numbers using the API?

Regards, Gerrit

Today is only yesterday's tommorrow - Uriah Heep
 
Square brackets for italics in your signature Gettit?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Of course, none of this helps with your real question. I'm sorry I can't help with that. I know that HMRC have a page where you can interactively check a given number, but you presumably want to do it automatically and in bulk.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

Automatically yes, in bulk no.

It’s difficult - at least for me - to get started. I guess I will have two challenges, the authentication and the webservice itself.

Regards, Gerrit
 
Gerrit,

This is a very crude call to the Web Service and response interpretation, but it demonstrates the fundamentals. Fortunately, the EORI check service is open so it's easy to set up.

Code:
LOCAL HTTP AS MSXML2.ServerXMLHTTP60

m.HTTP = CREATEOBJECT("MSXML2.ServerXMLHTTP.6.0")

LOCAL GBEORI AS String

m.GBEORI = "GB018384932372"		&& this is valid
* m.GBEORI = "GB925473846288"		&& this is not valid

LOCAL APIParameters AS String

TEXT TO m.APIParameters TEXTMERGE NOSHOW
{
 "eoris": [
    "<<m.GBEORI>>"
    ]
}
ENDTEXT

LOCAL IsValid AS Logical

m.HTTP.open("Post", "[URL unfurl="true"]https://test-api.service.hmrc.gov.uk/customs/eori/lookup/check-multiple-eori",[/URL] .F.)
m.HTTP.setRequestHeader("Accept", "application/vnd.hmrc.1.0+json")
m.HTTP.setRequestHeader("Content-Type", "application/json")
m.HTTP.send(m.APIParameters)

IF BETWEEN(m.HTTP.status, 200, 299)

	m.IsValid = '"valid":true' $ m.HTTP.responseText

ELSE

	m.IsValid = .NULL.

ENDIF

? m.GBEORI, m.IsValid
 
Hi António,

Thank you very much for posting this solution.

Apparently authentication is not required after all. The HMRC online information was confusing for me.

I'm already using your solution to validate EU EORI-numbers and will add this for UK validations.

Regards from Holland!

Gerrit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top