Skip to main content
Contributor I
January 24, 2024
Solved

i am triying to createProfile manually

  • January 24, 2024
  • 1 reply
  • 173 views


try {


    $body = array(
        'email' => 'test123@.net',
        'first_name' => 'test123',
        'phone_number'=>'1234567898',

    );


    $response = $klaviyo->Profiles->createProfile($body);


    print_r($response);
    
} catch (\Throwable $th) {
    print_r($th->getMessage());
}
 

 

but getting this error i check my api and filed they are correct but still i am getting this error

[400] Client error: `POST https://a.klaviyo.com/api/profiles/` resulted in a `400 Bad Request` response:{"errors":[{"id":"8fbddd01-a6ce-4675-bdbd-5e987bea6685","status":400,"code":"invalid","title":"Invalid input.","detail": (truncated...)
    This topic has been closed for replies.
    Best answer by Edmar Cruz

    Hi @zowumabuxo 

     

    You have the wrong format. Use the current JSON format available on Klaviyo API shown as follows

     

    {
      "data": {
        "type": "profile",
        "attributes": {
          "email": "sarah.mason@klaviyo-demo.com",
          "phone_number": "+15005550006",
          "external_id": "63f64a2b-c6bf-40c7-b81f-bed08162edbe",
          "first_name": "Sarah",
          "last_name": "Mason",
          "organization": "Klaviyo",
          "title": "Engineer",
          "image": "https://images.pexels.com/photos/3760854/pexels-photo-3760854.jpeg",
          "location": {
            "address1": "89 E 42nd St",
            "address2": "1st floor",
            "city": "New York",
            "country": "United States",
            "region": "NY",
            "zip": "10017",
            "timezone": "America/New_York",
            "ip": "127.0.0.1"
          },
          "properties": {
            "newKey": "New Value"
          }
        }
      }
    }

    1 reply

    Problem Solver I
    January 24, 2024

    Hi @zowumabuxo 

     

    You have the wrong format. Use the current JSON format available on Klaviyo API shown as follows

     

    {
      "data": {
        "type": "profile",
        "attributes": {
          "email": "sarah.mason@klaviyo-demo.com",
          "phone_number": "+15005550006",
          "external_id": "63f64a2b-c6bf-40c7-b81f-bed08162edbe",
          "first_name": "Sarah",
          "last_name": "Mason",
          "organization": "Klaviyo",
          "title": "Engineer",
          "image": "https://images.pexels.com/photos/3760854/pexels-photo-3760854.jpeg",
          "location": {
            "address1": "89 E 42nd St",
            "address2": "1st floor",
            "city": "New York",
            "country": "United States",
            "region": "NY",
            "zip": "10017",
            "timezone": "America/New_York",
            "ip": "127.0.0.1"
          },
          "properties": {
            "newKey": "New Value"
          }
        }
      }
    }