forecast_period: The end time is invalid.

60 views
Skip to first unread message

Simone Bonaretti

unread,
Oct 25, 2023, 4:55:58 AM10/25/23
to Google Ads API and AdWords API Forum
Hi,
I'm trying to make forecasts for a 12-month period, but I always encounter an error on the twelfth date. The same error occurs even when attempting a single forecast for a 12-month period.
How can I create a forecast for a period longer than 11 months?

Regards
Simone


[2023-10-25 10:10:40] local.DEBUG: DateRange:  
[2023-10-25 10:10:40] local.DEBUG: 2023-10-26  
[2023-10-25 10:10:40] local.DEBUG: 2023-11-26  
[2023-10-25 10:10:42] local.DEBUG: DateRange:  
[2023-10-25 10:10:42] local.DEBUG: 2023-11-26  
[2023-10-25 10:10:42] local.DEBUG: 2023-12-26  
[2023-10-25 10:10:44] local.DEBUG: DateRange:  
[2023-10-25 10:10:44] local.DEBUG: 2023-12-26  
[2023-10-25 10:10:44] local.DEBUG: 2024-01-26  
[2023-10-25 10:10:46] local.DEBUG: DateRange:  
[2023-10-25 10:10:46] local.DEBUG: 2024-01-26  
[2023-10-25 10:10:46] local.DEBUG: 2024-02-26  
[2023-10-25 10:10:49] local.DEBUG: DateRange:  
[2023-10-25 10:10:49] local.DEBUG: 2024-02-26  
[2023-10-25 10:10:49] local.DEBUG: 2024-03-26  
[2023-10-25 10:10:51] local.DEBUG: DateRange:  
[2023-10-25 10:10:51] local.DEBUG: 2024-03-26  
[2023-10-25 10:10:51] local.DEBUG: 2024-04-26  
[2023-10-25 10:10:53] local.DEBUG: DateRange:  
[2023-10-25 10:10:53] local.DEBUG: 2024-04-26  
[2023-10-25 10:10:53] local.DEBUG: 2024-05-26  
[2023-10-25 10:10:55] local.DEBUG: DateRange:  
[2023-10-25 10:10:55] local.DEBUG: 2024-05-26  
[2023-10-25 10:10:55] local.DEBUG: 2024-06-26  
[2023-10-25 10:10:57] local.DEBUG: DateRange:  
[2023-10-25 10:10:57] local.DEBUG: 2024-06-26  
[2023-10-25 10:10:57] local.DEBUG: 2024-07-26  
[2023-10-25 10:10:59] local.DEBUG: DateRange:  
[2023-10-25 10:10:59] local.DEBUG: 2024-07-26  
[2023-10-25 10:10:59] local.DEBUG: 2024-08-26  
[2023-10-25 10:11:01] local.DEBUG: DateRange:  
[2023-10-25 10:11:01] local.DEBUG: 2024-08-26  
[2023-10-25 10:11:01] local.DEBUG: 2024-09-26  
[2023-10-25 10:11:03] local.DEBUG: DateRange:  
[2023-10-25 10:11:03] local.DEBUG: 2024-09-26  
[2023-10-25 10:11:03] local.DEBUG: 2024-10-26  
[2023-10-25 10:11:03] local.DEBUG: {
    "message": "Request contains an invalid argument.",
    "code": 3,
    "status": "INVALID_ARGUMENT",
    "details": [
        {
            "@type": "type.googleapis.com\/google.ads.googleads.v14.errors.GoogleAdsFailure",
            "errors": [
                {
                    "errorCode": {
                        "requestError": "UNKNOWN"
                    },
                    "message": "The end time is invalid.",
                    "location": {
                        "fieldPathElements": [
                            {
                                "fieldName": "forecast_period"
                            }
                        ]
                    }
                }
            ],
            "requestId": "FTTj4N4F7MT1HS5JmoTL2Q"
        }
    ]
}




[2023-10-25 10:50:25] local.DEBUG: DateRange:  
[2023-10-25 10:50:25] local.DEBUG: 2023-10-26  
[2023-10-25 10:50:25] local.DEBUG: 2024-10-26  
[2023-10-25 10:50:25] local.DEBUG: {
    "message": "Request contains an invalid argument.",
    "code": 3,
    "status": "INVALID_ARGUMENT",
    "details": [
        {
            "@type": "type.googleapis.com\/google.ads.googleads.v14.errors.GoogleAdsFailure",
            "errors": [
                {
                    "errorCode": {
                        "requestError": "UNKNOWN"
                    },
                    "message": "The end time is invalid.",
                    "location": {
                        "fieldPathElements": [
                            {
                                "fieldName": "forecast_period"
                            }
                        ]
                    }
                }
            ],
            "requestId": "WX1tgnEnRZC5L9kBjIEpZQ"
        }
    ]
}  

Google Ads API Forum Advisor

unread,
Oct 26, 2023, 6:47:09 PM10/26/23
to simonebo...@gmail.com, adwor...@googlegroups.com
Hi Simone,

Thank you for reaching out to the Google Ads API support team.

After reviewing your concern, I understand that you are encountering an error with the error message "The end time is invalid." while trying to make forecasts via the Google Ads API for a 12-month period.

In order to assist you further, please provide us with the complete API logs (request and response with request-id and request header) generated at your end and the entire UI screenshot of the report that you are trying to duplicate via the Google Ads API.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java.NetPHPPythonRuby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.

 
This message is in relation to case "ref:!00D1U01174p.!5004Q02pW5cL:ref"

Thanks,
 
Google Logo Google Ads API Team


D. H.

unread,
Oct 29, 2023, 10:04:30 PM10/29/23
to Google Ads API and AdWords API Forum
The forecast period must be within one day from today (e.g., tomorrow) to within one year from today: https://developers.google.com/google-ads/api/reference/rpc/v15/GenerateKeywordForecastMetricsRequest

So when you were testing on 2023-10-25 the last date you could have requested was 2024-10-24.

I've tested this today, 2023-10-30. If I put in these parameters – start_date='2023-10-31', end_date='2024-10-29'– the API call returns valid results. This is the maximum forecast period possible.

If I put in these parameters – start_date='2023-10-31', end_date='2024-10-30' – the API call returns the same error you got:
GoogleAdsException: (<_InactiveRpcError of RPC that terminated with:
    status = StatusCode.INVALID_ARGUMENT
    details = "Request contains an invalid argument."
    debug_error_string = "UNKNOWN:Error received from peer ipv4:xxx.xxx.xxx.xx:xxx {grpc_message:"Request contains an invalid argument.", grpc_status:3, created_time:"2023-10-30T08:48:01.000000+08:00"}"
>, <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.INVALID_ARGUMENT
    details = "Request contains an invalid argument."
    debug_error_string = "UNKNOWN:Error received from peer ipv4:xxx.xxx.xxx.xx:xxx {grpc_message:"Request contains an invalid argument.", grpc_status:3, created_time:"2023-10-30T08:48:01.000000+08:00"}"
>, errors {
  error_code {
    request_error: UNKNOWN

  }
  message: "The end time is invalid."
  location {
    field_path_elements {
      field_name: "forecast_period"
    }
  }
}
request_id: "xxxxxxxxxxxxxxxxxxxxxx"
, '
xxxxxxxxxxxxxxxxxxxxxx')

It doesn't matter even if you put in a shorter period, the end date must be one day less than a year from now, e.g., if I put in start_date='2024-10-25', end_date='2024-10-31' to get the last week of October 2024 it returns the same end time is invalid error.

Hope this helps,

D.H.

Google Ads API Forum Advisor

unread,
Oct 30, 2023, 3:23:54 AM10/30/23
to heiberge...@gmail.com, adwor...@googlegroups.com
Hi, 


Thank you for reaching out to the Google Ads API support team. 

I see that you have already raised this concern on another thread with the subject "forecast_period: The end time is invalid." and we have already responded there for this issue. To avoid multiple threads on the same issue, please take a look at that thread and continue the discussion on the same for further updates on the issue.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02q948z:ref"


Thanks,
 
Google Logo Google Ads API Team


Google Ads API Forum Advisor

unread,
Oct 30, 2023, 3:26:58 AM10/30/23
to simonebo...@gmail.com, adwor...@googlegroups.com
Hi, 

Thank you for getting back to us. 

Please note that the provided logs are not complete. In order to further investigate your issue, kindly provide us with the complete API logs (request and response with request-id and request header) generated at your end and uncropped UI screenshot of the Google Ads account where you are facing the issue.
Reply all
Reply to author
Forward
0 new messages