HTTP query parameters not accepting array format

Describe the problem/error/question

I am using the Apollo people search API endpoint. One of the query parameters is called person_titles and expects and array of strings containing job titles. Here is an example from the docs: [“sales director”, “director sales”, “director, sales”].
I am copy and pasting this example from the docs into my http node query parameters (set to JSON).
{
“person_titles”: [“sales director”, “director sales”, “director, sales”]
}
For some reason I am getting the format error below:

What is the error message (if any)?

Your request is invalid or could not be processed by the service

person_titles requires an array. You are passing in ActiveSupport::HashWithIndifferentAccess

I then changed the parameter to the following:
{
“person_titles[ ]”: [“sales director”, “director sales”, “director, sales”]
}
which showed me this error:
Your request is invalid or could not be processed by the service

An ActiveSupport::HashWithIndifferentAccess is passed in for a String field {“0”=>“sales director”, “1”=>“director sales”, “2”=>“director, sales”}.

So I assume that the problem is n8n is converting my input to some sort of indexed array before passing it to the module but I have no idea how to prevent this and even why it is an issue.
Any help on how to tackle this would be very much appreciated I have spent way too much time on this ;(

Please share your workflow

It does not seem like my workflow is loading properly but the code is there.

Information on your n8n setup

  • n8n version: 1.85.4
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: Windows

The issue is that you confused query string url parameters with body content.
JSON goes into body, but the documentation talks about parameters:

curl --request POST \
     --url 'https://api.apollo.io/api/v1/mixed_people/search?person_titles[]=sales%20director&person_titles[]=director%20sales&person_titles[]=director%2C%20sales&person_locations[]=California%2C%20US&person_locations[]=Oregon%2C%20US&person_locations[]=Washington%2C%20US&per_page=5' \
     --header 'Cache-Control: no-cache' \
     --header 'Content-Type: application/json' \
     --header 'accept: application/json' \
     --header 'x-api-key: YOUR_API_KEY'

means that you have to enable “Send Query Parameters” and then specify which ones you need, for instance:

1 Like

Thank you @jabbson I was confused between the query parameter as stated in the docs for some reason and the POST body content. I put all my data into a json in the body and it worked.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.