Variable must be of type array

Describe the issue/error/question

Hi there!

I am trying to manually connect to the Plutio API to create a company, following their API docs (Plutio API) and it states that the contactEmails must be of type Array. How can I change the type to an array?

What is the error message (if any)?

“status”: “rejected”,

“reason”: {

“message”: “400 - {“code”:400,“message”:“Contact emails must be of type Array”}”,

“name”: “Error”,

“stack”: "Error: Request failed with status code 400 at createError

Please share the workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.163.1

I know this isn’t a very complex issue I’m just having trouble searching for the answer on my own. Thanks in advance! :slight_smile:

1 Like

Just set the contactEmails value to an expression instead of a string.

Thank you @RicardoE105!

I’m trying to use a variable in this array, is there a way for me to make it work like this?

It’s pulling the information from a form to create a company for them.

I’m running into this same issue with the array required to add a name on create.person.

Yes, but remove the extra {{}}. it should be {{$node["webhook"].json["body"]["question-4"]["reply"]}}

But now I’m back to it sending it as a string, right?

Do it like this: {{[$node["webhook"].json["body"]["question-4"]["reply"]]}}

Thank you! That made it an array.

Unfortunately, now it’s just throwing a different error at me :confused:

Ahh, then you do not need to send an array of strings but rather an array of objects. Sadly the docs does not mention the object key. I would try it like his:

{{[{ "email": $node["webhook"].json["body"]["question-4"]["reply"] } ]}}

1 Like

I thought for sure that would work but now just a different error.

Ok it looks like that is not the right structure. I would create a company from the UI, then retrieve all the companies using GET /companies to see how the contactEmails come in the response so that we can send it the same way when creating the company.

1 Like

@RicardoE105 good idea!

I found that the label it was expecting was “address”. It’s finally working.

Thank you :))

1 Like