Have a little problem pulling report from Google Ad Manager API based on startDate and endDate. Tbh I actually confused with the date format. Based on this link it ISO 8601's format 'YYYY-MM-DD'". but when I run the query I got this error:
In the documentation, it says 'There is a type mismatch in the request (e.g., an integer field has a string value).'. I get it, it probably confused with '-' symbol (i.e. 2024-04-21), so I deleted the '-' symbol and left it with integer values (i.e. 20240421). I ran my script again and I got this error . In the documentation it says that this error => 'Indicates that an unexpected error occured.' and I don't know what the '@' symbols mean?
# Create report job.
report_job = {
'reportQuery': {
'dimensions': ['DATE', 'AD_UNIT_NAME'],
'dimensionAttributes' : 'AD_UNIT_CODE',
'adUnitView': 'FLAT',
'reportCurrency': 'MYR',
'columns': ['TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS',
'TOTAL_LINE_ITEM_LEVEL_ALL_REVENUE'],
'dateRangeType': 'CUSTOM_DATE',
'startDate':'2024-04-29',
'endDate':'2024-05-05'
}
}
My Query to pull report.
I just want to pull historical report weekly based on specific startDate and endDate but I actually have no idea how the startDate and endDate work. I read the API document but still im confuse. Help will appriciated.
Apparently I found a way:
from datetime import date,timedelta
start_date = date(2024,4,21) # 21-04-2024
end_date = start_date + timedelta(days=6) # 27-04-2024
The query did not accept hardcoded string or int (I think..)