Solved

Triggering metric from API

  • 2 October 2023
  • 2 replies
  • 114 views

Badge

Hey, I'm trying to use a custom metric to trigger a flow from a third-party integration.

What I did is create a custom metric using the API, and then I created a flow and set its trigger to by the metric I created with the API. 

And now I'm trying to trigger the flow using this API end point: Track Profile Activity (klaviyo.com)

but for some reason I get 0 as a response which means the request has failed.

 

here is the code for the request: 

 

icon

Best answer by Brian Turcotte 9 November 2023, 20:14

View original

2 replies

Userlevel 7
Badge +36

Hi @raztamim!

I’m going to check with Engineering on this and I’ll update the thread ASAP!

Best,
Brian

Userlevel 7
Badge +36

Hi @raztamim!

My apologies for the delay here!

Are you able to try importing this request into a testing tool like Postman, so that we can determine if this is an issue with the payload data?

 

I tested on my account with Postman and the request was accepted (response: 1), simulating your payload as below:
 

curl --request POST \
--url https://a.klaviyo.com/api/track \
--header 'accept: text/html' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'data={"token": "PUBLIC_KEY", "event": "Ordered Product", "customer_properties": {"$email": "abraham.lincoln@klaviyo.com"}, "properties": {}}'

 

It also looks like your missing the header ‘accept: text/html’, although that’s probably not the issue. Also, I’d make sure you verify that the email address is valid before testing. If the call is accepted via Postman, then the issue will likely be found elsewhere in your code.


Best,
Brian

Reply