Unable to use start and end time while querying the API


#1

Hi - a quick query, while querying ads analytics I can get stats for a full day

e.g.

https://ads-api.twitter.com/2/stats/accounts/XXXXXX?entity=CAMPAIGN&entity_ids=XXXXX&start_time=2017-10-27&end_time=2017-10-28&granularity=TOTAL&placement=ALL_ON_TWITTER&metric_groups=ENGAGEMENT

gives me the metrics but the moment I want it for an hour it doesn’t accept the format and keeps giving UNAUTHORIZED_ACCESS response

https://ads-api.twitter.com/2/stats/accounts/XXXXXX?entity=CAMPAIGN&entity_ids=XXXXX&start_time=2017-10-27T11:00:00Z&end_time=2017-10-27T12:00:00Z&granularity=TOTAL&placement=ALL_ON_TWITTER&metric_groups=ENGAGEMENT

Any Idea what I could be doing wrong, the syntax seems to be correct but can’t to get the query working for intervals less than a day.

Thanks in Advance


#2

Hi,

Have you tried to repro this with the twurl command line tool? At a glance your format looks correct but I would check for things like unintended symbols or copy/paste problems and using either twurl or SDK can narrow those down.

Thanks,

John


#3

Thanks for the reply, yup, tried everything including postman and cmd line curl…just doesn’t work. Not sure if the account needs to have any special approval or authorization to query data less granular than a day?


#4

Two more things to look at, @krnK111:

  1. Guidance for UNAUTHORIZED_ACCESS issue
  2. Issue specific to time format and OAuth signatures

Given your original comment, you may want to focus on the second.

Hope this helps!


#5

Thanks - this has helped, changing the : to %3A and then firing the query gets the results.


#6

Wanted to also quickly ask (instead of creating another topic) if theres a way in the API to filter out expired campaigns somehow, so that means the status will be ACTIVE but they will still be expired??


#7

I think the end_time in the response should be the expiry status set in the UI?