klaviyo / klaviyo-php-sdk

PHP SDK for Klaviyo API
https://developers.klaviyo.com
MIT License
17 stars 9 forks source link

PHP SDK 400 bad request #10

Open Elliot-putt opened 1 year ago

Elliot-putt commented 1 year ago

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' => 'test@outlook.com', 'first_name' => 'elliot', 'title' => 'fddfasdsfaf', 'organization' => 'fsdfdsfsd', 'external_id' => '1234', 'anonymous_id' => '12345', 'image' => 'dfds']]]; $response = $klaviyo->Profiles->createProfile($array);

jon-batscha commented 1 year ago

Hey! Great question! (and thanks for reaching out)

This repo corresponds to our Legacy API (which we call v1-2 in various places). However, it looks like the call you are making corresponds to our new API, and it's related SDK. Hopefully this resolves your issue.

You are definitely not the first developer to raise this issue, so we have some work to do on our end to make this distinction clearer.

Please do reach out if you run into any further questions, either with this issue, or any future ones.

Cheers, Jon