CURLSMBS & OptionURL how to escape characters

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?

Sub Action()
  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.OptionVerbose=true
  
  c.OptionURL = CURLToSend
  c.CollectDebugData = false
  c.CollectOutputData = true
  c.CollectHeaderData=true
  dim title as string
  title=str(c.Perform)
  dim ss as string
  
  
  ss=ReplaceLineEndings(c.HeaderData,chr(9))
End Sub

in SS for the good address I get a location in the return string. This means it is a valid address in new zealand
Location: https://www.nzpost.co.nz/tools/address-postcode-finder/address/775199/51a-fifield-terrace-waltham-christchurch-8023

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.

Regards James

Have you tried EncodingToURLMBS?

Thanks I just did. it is the same as EncodeURLComponent .

Thanks though

Try replacing the / with a -

https://www.nzpost.co.nz/tools/address-postcode-finder/address/3077719/2-7-halswell-road-hillmorton-christchurch-8025

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 %2F.

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 “-”.

Good luck.

[quote=463874:@Andrew Lambert]Try replacing the / with a -

https://www.nzpost.co.nz/tools/address-postcode-finder/address/3077719/2-7-halswell-road-hillmorton-christchurch-8025

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.
Thank you