Skip to main content
Problem Solver I
April 14, 2024
Solved

Klaviyo Query Metric Aggregates API failing when paginating

  • April 14, 2024
  • 10 replies
  • 193 views

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

    This topic has been closed for replies.
    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

    10 replies

    Klaviyo Employee
    April 15, 2024

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

    Problem Solver I
    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

    Problem Solver I
    April 22, 2024

    checking back on this @saulblum thank you!

    Problem Solver I
    April 22, 2024

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

    Problem Solver I
    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

    Klaviyo Employee
    April 25, 2024

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

    Problem Solver I
    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? 

    Klaviyo Employee
    April 25, 2024

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

    Problem Solver I
    April 27, 2024

     

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

    SnapMetricsAuthorAnswer
    Problem Solver I
    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