Query LIKE filter triggering error

62 views
Skip to first unread message

Tiana S.

unread,
Oct 11, 2021, 9:39:20 AM10/11/21
to AdWords API and Google Ads API Forum
Hi there,

Question about the LIKE operator for filters. I have the following query:

SELECT metrics.clicks FROM campaign WHERE metrics.impressions > 0 AND campaign.name LIKE "%Gene[%" AND segments.date >= '2021-09-01' AND segments.date <= '2021-09-30'

When I put that query into the Query generator it states it's a valid query, but when I send it to the API I get the following error:

Error: 400 - {"error":{"code":400,"message":"Request contains an invalid argument.","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.ads.googleads.v8.errors.GoogleAdsFailure","errors":[{"errorCode":{"queryError":"INVALID_VALUE_WITH_LIKE_OPERATOR"},"message":"Value: %Gene[% is invalid. The LIKE operator may only be used with non-empty strings of valid Google SQL syntax."}],"requestId":"<REDACTED>"}]}}

Is there anything I might be doing wrong here?

Thank you,

Tiana

Google Ads API Forum Advisor

unread,
Oct 11, 2021, 11:08:10 PM10/11/21
to ti...@swydo.com, adwor...@googlegroups.com
Hi Tiana,

Thank you for reaching out. 

So that I can take a closer look, could you also share the complete request and response logs, with the request-id, generated when the error occurred? If you haven't 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.

You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2PIaQw:ref

Tiana S.

unread,
Oct 12, 2021, 2:37:53 AM10/12/21
to AdWords API and Google Ads API Forum
Hi Peter,

Thanks for getting back to me!

I sent the requested information privately.

Best,

Tiana

Google Ads API Forum Advisor

unread,
Oct 13, 2021, 1:11:00 AM10/13/21
to ti...@swydo.com, adwor...@googlegroups.com
Hi Tiana,

Thank you for providing the requested details privately. Let me reply here on this forum post for the benefit of the other advertisers that will encounter the same issue.

Upon impersonating the report on my end, I was able to replicate the issue. With this, I tried modifying the query to make it work, specifically removing the '['. The API request become successful and it appears that the said operation is not accepting special characters. That said, please try to remove the '[' and retry the API call again.

Let me know how it goes after trying the provided suggestion.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q2PIaQw:ref

Tiana S.

unread,
Oct 13, 2021, 5:18:07 AM10/13/21
to AdWords API and Google Ads API Forum
Hi Ernie,

Thanks for looking into this! 

Removing the [ works for the request but is it by design that special characters aren't supported in a LIKE operator's filter values?

Best,

Tiana

Google Ads API Forum Advisor

unread,
Oct 14, 2021, 1:50:48 AM10/14/21
to ti...@swydo.com, adwor...@googlegroups.com
Hi Tiana,

Thank you for the follow up question. Allow me to discuss it to the team and we will get back to you with an answer.

Google Ads API Forum Advisor

unread,
Oct 14, 2021, 3:50:11 PM10/14/21
to adwor...@googlegroups.com, ti...@swydo.com
Hi Tiana,

You need to escape the square braces using [].

[]] : matches the single character ']'
[[] : matches the single character '['

Let me know if that works for you.

Cheers,
Anash

ref:_00D1U1174p._5004Q2PIaQw:ref
Reply all
Reply to author
Forward
0 new messages