400 Bad Request using whatsapp templates - Values seems to not be valid

Problem Description:

I’m experiencing a consistent error when sending WhatsApp Business Cloud templates through n8n using positional variables.

Here’s a photo of my whatsapp template:

and here is a photo of my node config:

when I set default values (keeping the same amount of variables, I just change values) it works

Information on my n8n setup

  • n8n version: 1.106.3
  • Database: SQLite
  • Running n8n via: Docker
  • Operating system: Ubuntu 20.04

@lapiceroazul4 your one input value has a new line character (\n) at the end of the value .

It seems that the WhatsApp API does not like new line characters in template variable., I was also able to replicate this when adding a \n to the end of a variable value.

doing the same from Postman returns the detailed reason for the failure

Hope that solves your issue, if so, please mark this as the solution :slightly_smiling_face:

Hi mate, thanks for your reply. As you mentioned, the issue was indeed caused by the use of /n in the city field. However, I’ve recently run into the same problem again, and this time I haven’t been able to find the source of the error.

I’ve already cleaned the /n, tried converting all values into strings, and also removed blank spaces using trim(), but I’m still facing the same issue.

Additionally, I wanted to ask if you could explain how to get the Phone Number ID from Meta. I found this endpoint in the documentation, but I haven’t been able to locate the Phone Number ID to test the request in Postman.

I just kinda feel that the whatsapp node is not that good handling error messages (at least rn), I just decided to make the process using an http request and it works.

It seems that in your failed request posted above a required parameter is missing, this can happen when you have not configured the parameter and value in the node. Or when your flow tries to send an empty string / null value for one of the parameters.

Regarding the phone number ID, you can either get this from the Meta developer portal under WhatsApp → API Setup

or by using this API https://developers.facebook.com/docs/whatsapp/business-management-api/manage-phone-numbers#get-all-phone-numbers