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?