Single quotes in query

118 views
Skip to first unread message

Jobin Joy

unread,
Sep 15, 2023, 3:35:32 AM9/15/23
to Google Ads API and AdWords API Forum
Hi Team,
I have a requirement to pass single quotes in query as we have single quotes in search terms.
I tried adding a \ symbol for preceding a single quotes but I am getting response as below,
{
    "error": {
        "code": 400,
        "message": "Request contains an invalid argument.",
        "status": "INVALID_ARGUMENT",
        "details": [
            {
                "@type": "type.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure",
                "errors": [
                    {

                        "errorCode": {
                            "queryError": "BAD_VALUE"
                        },
                        "message": "Error in WHERE clause: invalid value '."
                    }
                ],
                "requestId": "xxxxx"
            }
        ]
    }
}

Request as follows,
{"pageSize": 10000,"query": "SELECT ad_group_criterion.keyword.text,
  campaign.name,
  ad_group.name
FROM keyword_view
WHERE ad_group_criterion.keyword.text IN ('Marine\'s Day Video','Video')"}

Could anyone kindly help me on this to pass single quotes in where condition? Thanks in advance

Google Ads API Forum Advisor

unread,
Sep 19, 2023, 8:16:53 AM9/19/23
to adwor...@googlegroups.com
Hi,

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

I would suggest you to try the following examples below :

If you're using single quotes ('), you would need an escape character (\) same as below :

WHERE
campaign.status IN ('ENABLED','PAUSED')
AND campaign.name IN ('Marine\'s Day Video')

However, when using double quotes ("), no need to include an escape character. See below :

WHERE
campaign.status IN ('ENABLED','PAUSED')
AND campaign.name IN ("Marine's Day Video")

I could see that your query is the same as the 1st example given. I would suggest you to retry the query from your end in both ways and provide us the complete request and response logs for further investigation.

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:_00D1U1174p._5004Q2olsZp:ref"

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages