Hi everyone Im using CURLSMBS to test addresses in my database to see if they are accurate for mailing using New Zealand Post.
I do so with the following code.
All is well until I have a “/” in my address and I get a bad request response.
Does anyone know how to escape this character please?
dim curlBADaddress as string ="2/7 Halswell Road, Hillmorton, Christchurch 8025"
dim curlGOODaddress as string ="51a Fifield Terrace, Waltham, Christchurch 8023"
dim CURLToSend as string ="https://www.nzpost.co.nz/tools/address-postcode-finder/suggest/"+ curlGOODaddress
dim c as new CURLSMBS
c.OptionURL = CURLToSend
c.CollectDebugData = false
c.CollectOutputData = true
dim title as string
dim ss as string
in SS for the good address I get a location in the return string. This means it is a valid address in new zealand
for the bad address i get a
HTTP/1.1 400 Bad Request
this code is mimicking testing an address at https://www.nzpost.co.nz/tools/address-postcode-finder.
The problem seems to be where an address has a “/” in it. How do i escape this character please.
Thanks heaps to anyione who can give me a headsup here.
Ive spent too many hours playing with encodings and all sorts.
Have you tried EncodingToURLMBS?
Thanks I just did. it is the same as EncodeURLComponent .
Try replacing the / with a -
I think the suggestion by @Andrew Lambert might be what you need.
Normally information like your addresses should be URL encoded. For example, spaces would be converted into either
%20 or the “
+” sign. And a slash “
/” would be
But after taking a quick look at the www.nzpost.co.nz site it looks like they might be using a custom encoding where it appears they are simply replacing non-letters and spaces with a hyphen “
[quote=463874:@Andrew Lambert]Try replacing the / with a -
I would like to say that it works Scott & Andrew , However…
I do get an OK 200 back, but it still doesn’t recognise the address
ie I dont get the location back in the header
Thanks Muchly for your time and suggestion
Do you have a working sample query from them with headers, so we can see how to pass values?
Doesn’t matter whether it’s postman, curl command line, php or something else.
[quote=464051:@Christian Schmitz]Do you have a working sample query from them with headers, so we can see how to pass values?
Doesn’t matter whether it’s postman, curl command line, php or something else.[/quote]
Hi Christian and thanks for your time.
This is only a workaround to use a consumer user web page via the URL to process a large number of addresses.
So they do not document anything I just found a way to get the data I wanted by sending the GET url and found data in the response header that I can use.
Thank you, but looking at this would waste your time on my problem. I just need to know a bit more about CURLSMBS requirements.
In case Im missing something. I just really needed to know if EncodeURLComponent or EncodingToURLMBS was the only thing that I can do to the string that I pass using OPTIONURL ?
Ie there is no funny linux way of escaping “/” needed for chars when using CURLSMBS , instead of or as well as urlencoding them.
I hope that makes sense.
Again I really appreciate everyones time.