Correctly Passing Multiple Array Items as Separate Query Parameters

Hello,

I’m encountering an issue with my module and need some help. I have a parameter questions[] which is an array of strings. The API I’m working with requires each item in the questions[] array to be passed individually as separate query parameters.

Here’s a summary of my issue:

  • Directly referencing the array (e.g., {{parameters.questions[]}}) results in only the first item being passed in the query string.
  • I attempted to use the join() function to properly format the questions[] array for the query string by joining the items with the separator &questions[]=.

However, the join() function doesn’t seem to be working as expected. Instead of correctly formatting the query string, it results in questions[] being sent with an empty string.

Here’s the relevant part of my code:

{
	// Request to API endpoint.
	"url": "/v1/job/asking",
    "method": "GET",
    "qs": {
        "board_key": "{{parameters.board_key}}",
        "key": "{{parameters.key}}",
        "reference": "{{parameters.reference}}",
		"questions[]": "{{join(parameters.`questions[]`;'&questions[]=')}}"
    },
	
	// Response handling
	"response": {
		"iterate": "{{body.data}}",
        "output": {
               "answer":"{{item}}"
                  }
	}
}```

Hi @hrflow.ai; what does the API documentation say for formatting the questions as an array?

Hi, the documentation doesn’t clearly explain how to format the questions. However, after some testing with Postman, I’ve discovered that each question should be passed as a ‘questions’ parameter in order for it to work. Here’s an example of the query string:

https://api.hrflow.ai/v1/job/asking?board_key=e467cdf4f97b5d091d811ef63192bf00a3011c5d&key=642cc18eedf775e464b3d130812fb374c4e9c33d&questions[]=What is the job title?&questions[]=Is there a start date for this position?

I resolved the issue by adding the questions parameter directly into the URL and using a questions key in the mappable parameters, instead of questions[]. The brackets in questions[] appeared to cause problems with make

{
	// Request to API endpoint.
	"url": "/v1/job/asking?{{'questions[]=' + join(parameters.questions;'&questions[]=')}}",
    "method": "GET",
    "qs": {
        "board_key": "{{parameters.board_key}}",
        "key": "{{parameters.key}}",
        "reference": "{{parameters.reference}}"
    },
...
}
3 Likes

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