klaviyo-php-sdk icon indicating copy to clipboard operation
klaviyo-php-sdk copied to clipboard

PHP SDK 400 bad request

Open Elliot-putt opened this issue 2 years ago • 1 comments

Hi all,

Just started using the Klaviyo SDK and after several hours and reading api guides and postman quiries i cannot figure this out.

This is my error below

[400] Client error: POST https://a.klaviyo.com/api/profiles/ resulted in a 400 Bad Request response: {"errors":[{"id":"edd7f096-d88a-4b8c-80cd-175250722bfe","status":400,"code":"invalid","title":"Invalid input.","detail": (truncated...)

So FYI i can make get request like this and everything works great:

$klaviyo->Lists->getList('******');

As soon as i want to make a post request i try to send an associative array over the the keys of data , type and attributtes and no matter what way i send this data i even tried json etc i get the above error could anyone help?

$array[] = ['data' => ['type' => 'profile', 'attributes' => ['email' => '[email protected]', 'first_name' => 'elliot', 'title' => 'fddfasdsfaf', 'organization' => 'fsdfdsfsd', 'external_id' => '1234', 'anonymous_id' => '12345', 'image' => 'dfds']]]; $response = $klaviyo->Profiles->createProfile($array);

Elliot-putt avatar Dec 21 '22 13:12 Elliot-putt