Skip to main content
Solved

Subscribing user to a list using the API

  • August 17, 2021
  • 3 replies
  • 1616 views

Forum|alt.badge.img+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

Best answer by jallain

@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.

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

jallain
Klaviyo Employee
Forum|alt.badge.img+11
  • Klaviyo Employee
  • 70 replies
  • Answer
  • August 17, 2021

@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.


Forum|alt.badge.img+2
  • Author
  • Contributor II
  • 4 replies
  • August 17, 2021

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 ! 


jallain
Klaviyo Employee
Forum|alt.badge.img+11
  • Klaviyo Employee
  • 70 replies
  • August 17, 2021

@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