Solved

Klaviyo Query Metric Aggregates API failing when paginating


Badge +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

icon

Best answer by SnapMetrics 27 April 2024, 14:10

View original

10 replies

Badge +1

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

Badge +1

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

Userlevel 5
Badge +7

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

Userlevel 5
Badge +7

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

Badge +1

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

Are you sure about it? 

Userlevel 5
Badge +7

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

Badge +1

thanks for sharing

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

thank you

Badge +1

 

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

Badge +1

checking back on this @saulblum thank you!

Badge +1

@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

Reply