400 error using the Facebook Conversion API

This topic was automatically generated from Slack. You can find the original thread here.

Elton Morais : I’m trying to create a Facebook Convervion using API. I already did that using PHP, trying just to adapt the code to nodejs, using axios, but just can’t get it to work. Receiving always error 400, without any info about the error.

Anyone here already created an nodejs that connects on Facebook Conversion API? If yes could you share what you did?

Elton Morais : I put the nodejs request and Postman request side by side. Postman body was a copy/paste from the nodejs console. Same data.

Elton Morais : On Postman it works. On nodejs error 400.

Elton Morais :

Dylan Sather (Pipedream) : Hi , does Facebook return any payload in the HTTP response indicating the reason for the 400?

Dylan Sather (Pipedream) : It shouldn’t matter in this case, but technically axios doesn’t need the data sent in the POST request to be converted to JSON. You can just send the JavaScript object directly without the JSON.stringify().

Dylan Sather (Pipedream) : You could also try using their Business SDK for Node - see the Node.js Business SDK tab in the example on this page: https://developers.facebook.com/docs/marketing-api/conversions-api/using-the-api

Pravin Savkar : another user shared a workflow on Twitter that demonstrates how to integrate with the Facebook Conversions API. I haven’t tried this myself, but I’m sharing in case the example is helpful:

Here is the link to the the original Twitter thread:

Elton Morais : , the problem was exactly with data. Use JSON.stringfy was generating the problem.

This way it worked:

image.png

Dylan Sather (Pipedream) : Great glad to hear that worked!


I have this error, what is the problem?

Hi @maximbruno97

A 400 error means that the data you’re sending to an external API doesn’t match what that API is expecting.

Please refer to the API’s documentation and the error message in the response from the API for more details to narrow down which part of the payload is missing or is malformed.

any good advice? I used the template in this post