I'm trying to query the product sold the last week froma GA4 property with googleAnalyticsR package.
I can run multiple queries for other metrics and dimensions but I keep getting an error for this specific query:
top_products_sold_last_week <- googleAnalyticsR::ga_data(property_id,
date_range = c(last_monday, last_sunday),
metrics = c("itemPurchaseQuantity", "itemRevenue", "averagePurchaseRevenue"),
dimensions = c("nthWeek", "itemId"),limit = -1)
Request failed [500]. Retrying in 1.8 seconds...
Request failed [500]. Retrying in 2.4 seconds...
i 2022-08-08 10:43:33 > Request Status Code: 500
i 2022-08-08 10:43:33 > Trying again: 1 of 1
i 2022-08-08 10:43:36 > All attempts failed.
Error in `abort_http()`:
! http_500 Internal error encountered.
last_monday and last sunday are dynamically generated and are both correct since in the other queries I get a correct response from the api.
I tried to manually query with the Query Explorer and I get a correct response, what am I missing?
This is the JSON request from the Query Explorer
{"dimensions":[{"name":"itemId"},{"name":"nthWeek"}],"metrics":[{"name":"averagePurchaseRevenue"},{"name":"itemPurchaseQuantity"},{"name":"itemRevenue"}],"dateRanges":[{"startDate":"2022-08-01","endDate":"2022-08-07"}]}