Question

POST Request to track events- "Data objects in the body is invalid"

  • 13 January 2022
  • 0 replies
  • 7 views

Hi everyone,

Is there an obvious mistake in the POST request below to the API endpoint? The response is 200 but it says one of the data objects is invalid. I cannot see what’s the problem though.

 

const formData = {

      "event": "Click pop up button",

      "properties": {

        "distinct_id": 1359,

        "token": <my project token>

      }

    }

    const options = {

      method: 'POST',

      headers: {Accept: 'text/plain', 'Content-Type': 'application/x-www-form-urlencoded'},

      body: formData

    };

   

    fetch('https://api.mixpanel.com/track', options)

      .then(response => response.json())

      .then(response => console.log(response))

      .catch(err => console.error(err));

 


0 replies

Be the first to reply!

Reply