[Python] Snapchat ads api - datetime & timezone for api calls results in failure due to...

Discussão em 'Python' iniciado por Stack, Fevereiro 4, 2025.

  1. Stack

    Stack Membro Participativo

    I am working on Snapchat Ads API. (Writing a connector to a big query). currently I get metrics(performance stats) at day's granularity. I pass the following as query parameters to the request URL.

    the accounts time zone: America/Los_Angeles

    I use the following date format successfully to retrieve data.

    2019-03-11T00:00:00.000-07:00 2019-03-12T00:00:00.000-07:00

    payload = {
    'granularity': 'DAY',
    'start_time': start_datetime,
    'end_time': end_datetime,
    'fields': fields
    }


    However, when I query for the date of 2019-03-10(I assume it is the daylight saving adjustment which causes this) it gives me the following error

    {'request_status': 'ERROR', 'request_id': 'xxxxxxxx', 'debug_message': "Unsupported Stats Query: Timeseries queries with DAY granularity must have a start time that is the start of day (00:00:00) for the account's timezone. This account's timezone is: America/Los_Angeles", 'display_message': "We're sorry, but the data provided in the request is incomplete or incorrect", 'error_code': 'E1008'}


    I also tried querying by adjusting for daylight saving adjustments. but not successful.

    2019-03-11T00:00:00.000-08:00 2019-03-12T00:00:00.000-08:00

    2019-03-11T00:00:00.000-06:00 2019-03-12T00:00:00.000-06:00

    There is no documentation available on: https://developers.snapchat.com/api/docs/

    Any help will be really appreciated. Thanks!

    Continue reading...

Compartilhe esta Página