Question

Creation of profile with email id failing

  • 18 April 2024
  • 2 replies
  • 20 views

Badge

Using the V2 api I could call the following to add a profile to a list.

    url = "{0}list/{1}/members".format(endpointURL, newsletterListId)
reqJson = {
"api_key": appConfig.KALVIYO_APIKEY,
"profiles": [
{
"email": email
}
]
}
r = requests.post(url, json=reqJson)

I am upgrading per the depreciation warning notifications.  The following taken from this documentation fails:

    url = "{0}lists/{1}/relationships/profiles/".format(endpointURL, newsletterListId)    

payload = {
"data": [
{
"type": "profile",
"email": email
}
]
}

headers = {
"accept": "application/json",
"revision": "2024-02-15",
"content-type": "application/json",
"Authorization": "Klaviyo-API-Key {0}".format(appConfig.KALVIYO_APIKEY)
}

response = requests.post(url, json=payload, headers=headers)

With error message:

{"errors":[{"id":"d871c72d-3c4e-46c6-a30a-66d526822741","status":400,"code":"invalid","title":"Invalid input.","detail":"The payload provided in the request is invalid.","source":{"pointer":"/data"},"meta":{}}]}

If I use the property name ‘id’ per the documentation (i.e. not ‘email’ as in the example above) I get this error:

{"errors":[{"id":"e4685613-85cd-45e6-921f-386e2543b537","status":400,"code":"invalid","title":"Invalid input.","detail":"Invalid profile IDs: {'doug@myemailaddress.com'}","source":{"pointer":"/data/"}}]}

I don’t store the klavio profile ID in our database, and so don’t actually have access to it.

How do I get this working, please?


2 replies

Userlevel 7
Badge +36

Hi @DougLapsley!

I’ll check on this with the API team and I’ll update the thread ASAP!

Best,
Brian

Userlevel 7
Badge +36

Hi @DougLapsley!

My apologies for the delay here! I’m still trying to hunt this information down - I will update the thread as soon as possible!
 

- Brian

Reply