Solved

Subscribing user to a list using the API

  • 17 August 2021
  • 3 replies
  • 1447 views

Badge +2

Hello everybody,

 

I’m integrating a popup for newsletter susbscription on a Prestashop website and I want to send the email registered to the API “list subscription”.

I already have an hook which is call after a newsletter subscription and call the “subscribeCustomer” function of the KlaviyoApiWrapper class with params: “email” => customer@mail.com and ‘customerProperties’ => []

 

The function is succefully called, but the problem is on API call I think, on “subscribeMemberToList” function, i have a request to:

url: https://a.klaviyo.com/api/v2/list/(my_list_id)/subscribe

with this body: 

{

    "profiles":[

        {

            "email":"exemple@mymail.com",

            "$phone_number":null,

            "$first_name":null,

            "$last_name":null,

            "$source":"PrestaShop",

            "$consent":[

                "email"

                ]

        }

    ]

}

 

And the request return an empty response with the status code 200 (success), but nothing is add on my list. I already tried to change the body on postman but i have the same problem:

 

{

    "profiles":[

        {

            "email":"exemple@mymail.com"

        }

    ]

}

 

someone have an idea ?

 

Thanks in advance,

Julien

icon

Best answer by jallain 17 August 2021, 16:00

View original

3 replies

Userlevel 4
Badge +11

@JulienLdt What are you getting back as a response aside from the 200 status code? Are you getting back an empty array? If the list is set to double opt-in, the profile won’t be added until they confirm via the confirmation email. If the response is an empty array then that is what is happening.

 

You can try making a request for an email that you have access to so you can see if you are getting the double opt-in email and once you confirm, see if you get added to the list.

Badge +2

Hello @jallain,

it was that. I’m not used to Klaviyo it was a mistake from my part..

Thank you for your help and have a good day ! 

Userlevel 4
Badge +11

@JulienLdt That’s great! Happy we could work through that together. Feel free to mark my last message as the solution in case other users encounter the same issue!

Reply