Skip to main content
Question

Passing an array object as HTTPCaller query string


I am trying to access a JSON API by using a HTTPCaller and I am struggling with passing an array object as a Query String Parameter. The documentation for the 'extra' key I am trying to access looks like this.

 

Request Query parametersThe code sample they give where you can see the 'extra' parameter as an array is here:

{

"key": "xxxxx-xxxxx-xxxxx-xxxxx",

"query": "High Street",

"country": "gbr",

"id": "town=Maidenhead",

"extra": {

"exclude_areas": [

"gbr_channel_islands",

"gbr_northern_ireland",

"usa_non_contiguous"

],

"exclude_pobox": true,

"best_match_only": true,

"no_groupings": true

}

}

 

How do I go about adding the extra array as a query string parameter when the API is expecting to be given an array?

 

many thanks in advance

4 replies

david_r
Evangelist
  • March 23, 2023

You'll have to URL encode the JSON document before the HTTPCaller using the TextEncoder, e.g.:

image


  • Author
  • March 23, 2023
david_r wrote:

You'll have to URL encode the JSON document before the HTTPCaller using the TextEncoder, e.g.:

image

Thanks David - I am missing a step I think.

if I pass the text I think I need to the Textencoder ie

{

   "best_match_only": true,

}

the encoded output is %7B%0A%09%22best_match_only%22%3A%20true%2C%0A%7 which the HTTPCaller still interprets as a string - what have a missed?


david_r
Evangelist
  • March 23, 2023
mfgt84 wrote:

Thanks David - I am missing a step I think.

if I pass the text I think I need to the Textencoder ie

{

   "best_match_only": true,

}

the encoded output is %7B%0A%09%22best_match_only%22%3A%20true%2C%0A%7 which the HTTPCaller still interprets as a string - what have a missed?

That is correct. Query parameters are always sent as strings, although the server may interpret it as something else once the string data arrives.

 


  • Author
  • March 23, 2023
mfgt84 wrote:

Thanks David - I am missing a step I think.

if I pass the text I think I need to the Textencoder ie

{

   "best_match_only": true,

}

the encoded output is %7B%0A%09%22best_match_only%22%3A%20true%2C%0A%7 which the HTTPCaller still interprets as a string - what have a missed?

I think it might be an issue I can't overcome, as the API always seems to interpret what it is passed as a string. Thank you for your help though


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings