correct syntax for VanityPharma feild

71 views
Skip to first unread message

reid hommedahl

unread,
Jul 6, 2021, 4:06:03 PM7/6/21
to AdWords API and Google Ads API Forum

Hello,

I just ran the GetCampaigns.java file successfully, and now I want to add a row to the GAQL query-- VanityPharmaText

Here's the String query I have:

private void runExample(GoogleAdsClient googleAdsClient, long customerId) {
  try (GoogleAdsServiceClient googleAdsServiceClient =
  googleAdsClient.getLatestVersion().createGoogleAdsServiceClient()) {
String query = "SELECT campaign.id, campaign.name, campaign.vanity_pharma.vanity_pharma_text, FROM campaign ORDER BY campaign.id";

It's returning this error:

Failure message: errors {

  error_code {

    query_error: BAD_FIELD_NAME

  }

  message: "Error in SELECT clause: invalid field name \'FROM\'."

}

request_id: "xRpoPouoBilEUsq8qsD4Fg"


Status: Status{code=INVALID_ARGUMENT, description=Request contains an invalid argument., cause=null}.

Request ID xRpoPouoBilEUsq8qsD4Fg failed due to GoogleAdsException. Underlying errors:

  Error 0: error_code {

  query_error: BAD_FIELD_NAME

}

message: "Error in SELECT clause: invalid field name \'FROM\'."

___________________________________________________________________________

What is the correct way to write this? Thank you in advance for the help!

GAQL String.PNG
GAQL String error.PNG

reid hommedahl

unread,
Jul 7, 2021, 4:58:33 PM7/7/21
to AdWords API and Google Ads API Forum

Hi,

Just wanted to follow up here.

I'm sure it's a simple fix. Any suggestions?

Thank you.

Google Ads API Forum Advisor

unread,
Jul 12, 2021, 1:14:27 PM7/12/21
to adwor...@googlegroups.com
Hello,

Thanks for your patience. The SELECT statement of a query must only include supported resource fields, segments and metrics. If you want to filter your query, you can use a WHERE statement. For example, if you wanted to report only the last seven days, you would include the WHERE statement in your query,

"WHERE segments.date DURING LAST_7_DAYS "
 
Please see this guide for more information on retrieving objects. The query validator is also useful for ensuring your query is valid.

Regards,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 

 


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