Skip to main content
Solved

Klaviyo Query Metric Aggregates API failing when paginating


Forum|alt.badge.img+1

Hi,

Getting “Method Not Allowed” when using the pagination link, ex:

https://a.klaviyo.com/api/metric-aggregates/?page[cursor]=BASE64_HERE

Using GET method on it and everything else is working.. only when viewing next page…

What could be the reason?


Thank you

Best answer by SnapMetrics

Found the solution was actually post the entire original query in the body…

So again for anyone else coming here

Problem: pagination for metric aggregates returning “method not allowed”

Solution: it’s actually a POST request, and you need to post the query body to the next page link

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

10 replies

Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • April 15, 2024

Hi! Query Metric Aggregates is a POST request, have you tried making a POST to the paginated next links?


Forum|alt.badge.img+1
  • Author
  • Problem Solver I
  • 6 replies
  • April 19, 2024

thanks for sharing

what do I include in the post body? the same query I had in the first page?

thank you


Forum|alt.badge.img+1
  • Author
  • Problem Solver I
  • 6 replies
  • April 22, 2024

checking back on this @saulblum thank you!


Forum|alt.badge.img+1
  • Problem Solver I
  • 6 replies
  • April 22, 2024

@SnapMetrics Hi, FYI v1/v2 legacy APIs are scheduled to retire on June 30, 2024.


Forum|alt.badge.img+1
  • Author
  • Problem Solver I
  • 6 replies
  • April 22, 2024

@Arif Astori thank you, I am not using them

 

the documentation on pagination though is not clear yet… I can see the next/previous links, but you can’t GET them… you need to POST apparently and its still not clear whats expected in the body


Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • April 25, 2024

There’d no no body in the POST to the pagination links, since their query params already store the original request.


Forum|alt.badge.img+1
  • Author
  • Problem Solver I
  • 6 replies
  • April 25, 2024

I can’t make a POST request without a body, it shows an error that it’s empty…

Are you sure about it? 


Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • April 25, 2024

In Postman? Via code? You should be able to POST to a URL without a JSON body.


Forum|alt.badge.img+1
  • Author
  • Problem Solver I
  • 6 replies
  • April 27, 2024

 

This is a response from Klaviyo API when making a POST request to the next page URL...


Forum|alt.badge.img+1
  • Author
  • Problem Solver I
  • 6 replies
  • Answer
  • April 27, 2024

Found the solution was actually post the entire original query in the body…

So again for anyone else coming here

Problem: pagination for metric aggregates returning “method not allowed”

Solution: it’s actually a POST request, and you need to post the query body to the next page link