Skip to main content

Solved

12452 Topics
passing profiles to the https://a.klaviyo.com/api/v2/list/{list_id}/members endpoint

HelloI need help sending data to https://a.klaviyo.com/api/v2/list/{list_id}/members using javascript.getting error msg as  “Error sending event:” Please see my code below:   const apiKey = 'my api ';       const url = `https://a.klaviyo.com/api/v2/list/{list_id}/members`;    // The data to be sent as the request body    const data = {        api_key: apiKey,        profiles: [            {                email: 'test@example.com',                $first_name: 'Test',                $last_name: 'Test',                $phone_number: '206-234-2345',                $response: "1"            }        ]    };    // Options for the fetch() function    const options = {        method: 'POST',        headers: {            'Content-Type': 'application/json'        },        body: JSON.stringify(data)    };    // Send the request using fetch()    fetch(url, options)        .then(response => {            alert("response.json() =" + response.json());            if (response.ok) {              Â