XML Processing for function (1 Viewer)

MrHans

Registered User
Local time
Today, 13:53
Joined
Jul 27, 2015
Messages
147
I checked and indeed you can link your API Key to a domain, so only calls made from the specified domain are accepted.
You cab ignore that bit, I don't have it set either.
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:53
Joined
Jan 23, 2006
Messages
15,394
I tried using your GetAddress function with this small routine

Code:
Sub MrHansTest()
Dim zip As String: zip = "1234AB"
Dim HouseNumber As String: HouseNumber = "10"
Debug.Print "MrHans test" & vbCrLf
Debug.Print GetAddress(zip, HouseNumber)
End Sub

I used my newly created and activated apikey in your function.
I used the zip and housenumber as you had in your first post.

I am receiving error code 7 Invalid Domain???

What exactly do they mean by domain?????

I tried running the sql string directly in the browser and also got error 7

I did some poking around and got this message

translated to English via Google translate

Error in the application
There is an error in the application. Our webmaster is informed accordingly by e-mail and will check the problem as soon as possible. We ask you to try again later. We apologize for the inconvenience.
If you know how to reproduce this error, please let us know, of course. In that case, please contact us.
 
Last edited:

MrHans

Registered User
Local time
Today, 13:53
Joined
Jul 27, 2015
Messages
147
You should just call the procedure like this:
?GetAddress("1234AB","30")

That should print the results directly in your immediate window. I don't know about that domain, I don't have it set and it's also not required.
 

MrHans

Registered User
Local time
Today, 13:53
Joined
Jul 27, 2015
Messages
147
I think you enabled the domain limitation setting in your account, it should be set to 'nee'
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:53
Joined
Jan 23, 2006
Messages
15,394
I tired your suggestion with my account as it was

Code:
?GetAddress("1234AB","30")
http://api.postcodes.nl/1.0/address/?apikey=MY api key here&nlzip6=1234AB&streetnumber=30
{"status":"error","errorcode":7,"errormessage":"invalid domain"}

I then went into postcodes.nl and set the Nee,
then reran the code
Code:
?GetAddress("1234AB","30")
http://api.postcodes.nl/1.0/address/?apikey=My API KEY IN HERE&nlzip6=1234AB&streetnumber=30
{"status":"error","errorcode":11,"errormessage":"no results"}

Tried again ( activated the output=xml) I had it turned off to see the JSON defaults.

Code:
?GetAddress("4567ab","30")
http://api.postcodes.nl/1.0/address/?apikey=AGAIN MY API KEY IS HERE&nlzip6=4567ab&streetnumber=30&output=xml
<?xml version="1.0" encoding="UTF-8"?>
<response><status>ok</status><results><result><nlzip6>4567ab</nlzip6><streetname>'s Gravenstraat</streetname><city>Clinge</city><municipality>Hulst</municipality><province>Zeeland</province><latitude>51.275967</latitude><longitude>4.090978</longitude><phoneareacode>0114</phoneareacode></result></results></response>
's Gravenstraat 30
4567ab Clinge
Zeeland

So, it is working.

And this is the JSON response
Code:
?GetAddress("4567ab","30")
http://api.postcodes.nl/1.0/address/?apikey=MY API KEY HERE&nlzip6=4567ab&streetnumber=30
{"status":"ok","results":[{"nlzip6":"4567ab","streetname":"'s Gravenstraat","city":"Clinge","municipality":"Hulst","province":"Zeeland","latitude":"51.275967","longitude":"4.090978","phoneareacode":"0114"}]}

And my original MrHans test
Code:
Sub MrHansTest()
Dim zip As String: zip = "4567BD"
Dim HouseNumber As String: HouseNumber = "5"
Debug.Print "MrHans test" & vbCrLf
Debug.Print GetAddress(zip, HouseNumber)
End Sub

Produces:

I did ask to have the responseText displayed:
<?xml version="1.0" encoding="UTF-8"?>
<response><status>ok</status><results><result><nlzip6>4567BD</nlzip6><streetname>Molenstraat</streetname><city>Clinge</city><municipality>Hulst</municipality><province>Zeeland</province><latitude>51.263161</latitude><longitude>4.072469</longitude><phoneareacode>0114</phoneareacode></result></results></response>

Molenstraat 5
4567BD Clinge
Zeeland

Thanks for sticking with me to get this working.
It was a bit of an ordeal to translate everything via Google translate --and I never did see a definition/instruction re Domain =Nee Thanks again.
 
Last edited:

MrHans

Registered User
Local time
Today, 13:53
Joined
Jul 27, 2015
Messages
147
Excellent, yes this is the correct response.
In my production code I just add all tags to an collection object, then you can just retrieve the streetname for example from the collection
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:53
Joined
Jan 23, 2006
Messages
15,394
Great.
I'm sure there is a way to parse the JSON. Perhaps that can be another exercise.
 

Users who are viewing this thread

Top Bottom