Hey, 
For comparison reasons I am attaching the two requests:

*Successful Request* 
(*URL*=/v12/customers/5502278799/googleAds:search?query=SELECT+customer.descriptive_name%2C+customer.id%2C+campaign.name%2C+campaign.id%2C+ad_group.name%2C+ad_group.id%2C+metrics.impressions%2C+metrics.clicks%2C+metrics.conversions%2C+metrics.cost_micros%2C+ad_group_ad.ad.id%2C+ad_group_ad.ad.name+FROM+ad_group_ad+WHERE+segments.date+%3E%3D+%272022-12-25%27+AND+segments.date+%3C%3D+%272023-04-14%27&page_size=10000
 
)

*1. Here's the Request's Headers:*

{'User-Agent': 'python-requests/2.28.2', 'Accept-Encoding': 'gzip, 
deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Authorization': 
'Bearer xxxxx', 'Content-Type': 'application/json', 'developer-token': 
'xxxxxx', 'Content-Length': '0'} 

*2. Here's the Response's Headers:*
{'Request-Id': 'nrVY8qX8ooo9aqVgmV7pBg', 'Content-Type': 'application/json; 
charset=UTF-8', 'Vary': 'Origin, X-Origin, Referer', 'Content-Encoding': 
'gzip', 'Date': 'Wed, 19 Apr 2023 13:07:13 GMT', 'Server': 'ESF', 
'Cache-Control': 'private', 'X-XSS-Protection': '0', 'X-Frame-Options': 
'SAMEORIGIN', 'X-Content-Type-Options': 'nosniff', 'Alt-Svc': 'h3=":443"; 
ma=2592000,h3-29=":443"; ma=2592000', 'Transfer-Encoding': 'chunked'}

*3. Here's the Response's Content:*
b'{\n  "results": [\n    {\n      "customer": {\n        "resourceName": 
"customers/5502278799",\n        "id": "5502278799"\n      },\n     
 "campaign": {\n        "resourceName": 
"customers/5502278799/campaigns/18703667903",\n        "name": "SIEM 
Detections",\n        "id": "18703667903"\n      },\n      "adGroup": {\n   
     "resourceName": "customers/5502278799/adGroups/144472332164",\n       
 "id": "144472332164",\n        "name": "Smart Campaign Managed AdGroup"\n 
     },\n      "metrics": {\n        "clicks": "0",\n        "conversions": 
0,\n        "costMicros": "0",\n        "impressions": "0"\n      },\n     
 "adGroupAd": {\n        "resourceName": 
"customers/5502278799/adGroupAds/144472332164~630444154971",\n        "ad": 
{\n          "resourceName": "customers/5502278799/ads/630444154971",\n     
     "id": "630444154971"\n        }\n      }\n    }\n  ],\n  "fieldMask": 
"customer.descriptiveName,customer.id,campaign.name,campaign.id,adGroup.name,adGroup.id,metrics.impressions,metrics.clicks,metrics.conversions,metrics.costMicros,adGroupAd.ad.id,adGroupAd.ad.name"\n}\n'


*Failed Request *(*URL* 
= 
/v12/customers/5502278799/googleAds:search?query=SELECT+customer.descriptive_name%2C+customer.id%2C+campaign.name%2C+campaign.id%2C+ad_group.name%2C+ad_group.id%2C+metrics.impressions%2C+metrics.clicks%2C+metrics.conversions%2C+metrics.cost_micros%2C+ad_group_ad.ad.id%2C+ad_group_ad.ad.name%2C+
*segments.date*+FROM+ad_group_ad+WHERE+segments.date+%3E%3D+%272022-12-25%27+AND+segments.date+%3C%3D+%272023-04-14%27&page_size=10000
 
)

*1. Here's the Request's Headers:*
{'User-Agent': 'python-requests/2.28.2', 'Accept-Encoding': 'gzip, 
deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Authorization': 
'Bearer xxxxx', 'Content-Type': 'application/json', 'developer-token': 
'xxxxxx', 'Content-Length': '0'}

*2. Here's the Response's Headers:*
{'Request-Id': 'mxvqIbNyPvvNvs_jESvenQ', 'Content-Type': 'application/json; 
charset=UTF-8', 'Vary': 'Origin, X-Origin, Referer', 'Content-Encoding': 
'gzip', 'Date': 'Wed, 19 Apr 2023 13:13:09 GMT', 'Server': 'ESF', 
'Cache-Control': 'private', 'X-XSS-Protection': '0', 'X-Frame-Options': 
'SAMEORIGIN', 'X-Content-Type-Options': 'nosniff', 'Alt-Svc': 'h3=":443"; 
ma=2592000,h3-29=":443"; ma=2592000', 'Transfer-Encoding': 'chunked'}


*3. Here's the Response's Content:*b'{\n  "fieldMask": 
"customer.descriptiveName,customer.id,campaign.name,campaign.id,adGroup.name,adGroup.id,metrics.impressions,metrics.clicks,metrics.conversions,metrics.costMicros,adGroupAd.ad.id,adGroupAd.ad.name,segments.date"\n}\n'


If the Tokens are required, please let me know, and I will send a 
designated URL containing those.

I am looking forward to your response,

Best Regards 
Yaar


On Tuesday, April 18, 2023 at 4:24:54 PM UTC+3 Google Ads API and AdWords 
API Forum wrote:

Hi,

Thank you for getting back to us. I hope that you are doing well today. 

I understand your concern and as mentioned here in this document 
<https://developers.google.com/google-ads/api/docs/reporting/segmentation#rules_for_core_date_segment_fields>,
 
the segments.date, segments.week, segments.month, segments.quarter, and 
segments.year can be filtered in the WHERE clause without appearing in the 
SELECT clause. However, to further investigate the issue, could you please 
provide us the complete request 
<https://developers.google.com/google-ads/api/docs/concepts/field-service#request>
 
and response 
<https://developers.google.com/google-ads/api/docs/concepts/field-service#response>
 
logs with request ID 
<https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id>
 
and request header 
<https://developers.google.com/google-ads/api/docs/concepts/call-structure#request_headers>
 
generated on your end? You can provide it via Reply privately to the author 
option. If this option is not available, then send it instead on this email 
address googleadsa...@google.com. If you haven't enabled the logging yet, 
logging can be enabled by navigating to the Client libraries > Your client 
library (ex. Java) > Logging documentation, which you can access from this 
link <https://developers.google.com/google-ads/api/docs/client-libs?hl=en>.

Kind regards,
Google Ads API
On Tuesday, April 18, 2023 at 8:04:14 PM UTC+8 Google Ads API and AdWords 
API Forum wrote:

Re-posting the last inquiry (
https://groups.google.com/g/adwords-api/c/Yfsqi2GGHco) from the forum as it 
wasn't routed to our support queue.

Regards,
Google Ads API Team
On Tuesday, April 18, 2023 at 5:04:28 PM UTC+8 yaa...@rivery.io wrote:

Hi Google Ads API team!
I am not sure what is the issue, but the docs that were sent are stating 
that the query is valid, just like the Query Validator screenshot I 
attached in the first message shows. 
Having the *segments.date* field in the WHERE clause is valid, and when I 
add the *segments.date* field to the SELECT clause, the validator shows it 
is valid too - but executing the API request retrieves no data when 
including it in the SELECT clause.
I am not sure what the problem is here and would love your assistance in 
resolving it. 
If more information needs to be provided - please let me know what I should 
add to resolve it.

On Monday, April 17, 2023 at 4:41:39 PM UTC+3 Google Ads API and AdWords 
API Forum wrote:

Hi,

Thank you for raising this issue to the Google Ads API support team.

Regarding your concern, you mentioned that you are getting empty results 
using the above query but when you remove the *segments.date* from the 
Select clause, you are able to get data. Having said that, I would suggest 
referring to our *Segmentation* and *Rules for segments in the WHERE clause* 
guides as this contains more details about this.

Links included in this email:

   - *Segmentation - *
   https://developers.google.com/google-ads/api/docs/reporting/segmentation
   - *Rules for segments in the WHERE clause - *
   
https://developers.google.com/google-ads/api/docs/reporting/segmentation#rules_for_segments_in_the_where_clause
   

Regards,
Google Ads API Team
On Monday, April 17, 2023 at 7:49:36 PM UTC+8 yaa...@rivery.io wrote:

This query fails to retrieve data, even though it gets a 200 status_code 
when executing in Python:

url= 'https://googleads.googleapis.com/v12/customers/XXXXXX/googleAds:search
'
params_search= {"query": "SELECT customer.descriptive_name, customer.id, 
campaign.name, campaign.id, ad_group.name,"
" ad_group.id, metrics.impressions, metrics.clicks, metrics.conversions, "
"metrics.cost_micros, ad_group_ad.ad.id, ad_group_ad.ad.name, segments.date 
FROM ad_group_ad "
"WHERE segments.date >= '2022-12-25' AND segments.date <= '2023-04-14'",
"page_size": 10000}

Here's the text response to this API request:
'
{
  "fieldMask": "customer.descriptiveName,customer.id,campaign.name,
campaign.id
,adGroup.name,adGroup.id,metrics.impressions,metrics.clicks,metrics.conversions,metrics.costMicros,
adGroupAd.ad.id,adGroupAd.ad.name,segments.date"
}
'

When I removed the *segments.date* from the Select clause, the API request 
retrieves data back successfully.

This shows that it is a valid API request in the Query Validator:
[image: Untitled.png]


Is there a problem using *segments.date* in the select clause, or is it 
possible that there's just no data for the *segments.date* for these time 
frames, or something else?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/ef48855d-0b16-48e0-a703-b3392f722242n%40googlegroups.com.
  • Re... Google Ads API and AdWords API Forum
    • ... Google Ads API and AdWords API Forum
      • ... 'Yaar Or' via Google Ads API and AdWords API Forum
        • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
          • ... 'Yaar Or' via Google Ads API and AdWords API Forum

Reply via email to