Skip to main content
Solved

Python API create_event -- value.error


Forum|alt.badge.img+1

Hello,

 I’m trying the latest python sdk v6.1.0 .   I’m trying to do a simple create event call and I’m getting an error.   I’ve copied the payload directly from the docs, and the “get” queries are working, so i’m not sure what the issue is…  Has anyone else run into this? I’ve tried many different payload formats but i’m not sure what is missing.

 

thanks,

k

 

klaviyo = KlaviyoAPI(settings.KLAVIYO_PRIVATE_KEY, max_delay=60, max_retries=3, test_host=None)

payload = {'data': {'type': 'event',
  'attributes': {'properties': {'action': 'Reset Password'},
   'metric': {'data': {'type': 'metric',
     'attributes': {'name': 'Reset Password'}}},
   'profile': {'data': {'type': 'profile',
     'attributes': {'email': 'sarah.mason@klaviyo-demo.com'},
     'properties': {'PasswordResetLink': 'https://www.website.com/reset/1234567890987654321'}}},
   'unique_id': '4b5d3f33-2e21-4c1c-b392-2dae2a74a2er'}}}

result = klaviyo.Events.create_event(data=payload)

ValidationError: 1 validation error for CreateEvent
event_create_query_v2
  field required (type=value_error.missing)

 

Best answer by KeithPYC

I’m not sure how to remove this, so i’ll leave it up... in case anyone else makes the same mistake ,the fix was that I had the wrong kwarg.

 

klaviyo.Events.create_event(data=payload) should just be klaviyo.Events.create_event(payload), and everything works alot better.

 

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

2 replies

Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 1 reply
  • Answer
  • January 23, 2024

I’m not sure how to remove this, so i’ll leave it up... in case anyone else makes the same mistake ,the fix was that I had the wrong kwarg.

 

klaviyo.Events.create_event(data=payload) should just be klaviyo.Events.create_event(payload), and everything works alot better.

 


Brian Turcotte
Forum|alt.badge.img+37

Hi @KeithPYC!

Thanks so much for sharing your solution with the Community!
 

- Brian