Question

Passing an array object as HTTPCaller query string

  • 23 March 2023
  • 4 replies
  • 62 views

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

Userlevel 4

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

image

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?

Userlevel 4

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.

 

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

Reply