Google Ads REST Interfaces struggle us so much.

324 views
Skip to first unread message

zhang john

unread,
Aug 11, 2023, 3:35:39 AM8/11/23
to Google Ads API and AdWords API Forum
Hi There,
We're developing one Ads application based on  Google Ads API.
Due to some technical reasons, it's difficult for us to use the Google Ads Client Library,
so we had to implement it by using the Google Ads REST interface.

Currently,we managed to mutate and search Campaign/Budget/AdGroup/Account via its REST Interface.
However, there are still some big questions struggling us.

1.Which fields are basic and required to create a common and simple Ads?
2.Which endpoint is provided to set the specific Audience-Dimension(Age/Gender/Area/Interest etc).
 
Great appreciate if someone could help us on them.

Best regards,
John

Google Ads API Forum Advisor

unread,
Aug 11, 2023, 8:12:42 AM8/11/23
to johnzh...@gmail.com, adwor...@googlegroups.com

Hi John,

Thank you for reaching out to Google Ads API Forum. Please see responses to your questions below.

Which fields are basic and required to create a common and simple Ads?

Which endpoint is provided to set the specific Audience-Dimension(Age/Gender/Area/Interest etc).

Please let us know if you have further questions.

This message is in relation to case "ref:_00D1U1174p._5004Q2nquf7:ref"

Thanks,
 
Google Logo Google Ads API Team


zhang john

unread,
Aug 23, 2023, 11:08:13 PM8/23/23
to Google Ads API and AdWords API Forum
1.Which one should I attach the Audience to, Campaign or Ad Group or AdGroup Ad?

2.I managed to create a basic Audience (that only contains Age/Gender/Household Income/Parental Status) customers/3869257274/audiences/89957000
   How to create one advanced Audience that contains AudienceSegment?

Google Ads API Forum Advisor

unread,
Aug 24, 2023, 6:31:06 AM8/24/23
to johnzh...@gmail.com, adwor...@googlegroups.com

Hi John,

 

For your first concern, I'm afraid that it would depend on your use-case as well as which type of campaign you're using. Kindly note that audience targeting is supported for performance max and discovery campaigns:

 

For creating an audience with audience segments, you would need to use the AudienceService <https://developers.google.com/google-ads/api/reference/rpc/v14/AudienceService> and specify your AudienceDimension <https://developers.google.com/google-ads/api/reference/rpc/v14/AudienceDimension> into AudienceSegmentDimension <https://developers.google.com/google-ads/api/reference/rpc/v14/AudienceSegmentDimension> with segments[] <https://developers.google.com/google-ads/api/reference/rpc/v14/AudienceSegment>.

 

Let us know if you have any clarifications.

zhang john

unread,
Aug 24, 2023, 10:16:41 PM8/24/23
to Google Ads API and AdWords API Forum
I am trying to attach some criterion to my campaign  20425685181  .
I managed to add several  criterions  `LOCATION`/ `LANGUAGE`/`DEVICE` respectively for the campaign  

However, it got errors when I try to attach 'USER_INTEREST' and 'GENDER' to it.
Please check this two error responses from REST API.

--------------------------
{ "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": { "criterionError": "INVALID_USER_INTEREST" }, "message": "Invalid user interest criterion.", "trigger": { "int64Value": "259" }, "location": { "fieldPathElements": [ { "fieldName": "operations", "index": 0 }, { "fieldName": "create" }, { "fieldName": "user_interest" }, { "fieldName": "user_interest_category" } ] } } ], "requestId": "A_POyf23iGnRt6UMkWIpew" } ] } }

{ "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": { "criterionError": "FIELD_INCOMPATIBLE_WITH_NEGATIVE_TARGETING" }, "message": "The field is not allowed to be set when the negative field is set to true, for example, we don't allow bids in negative ad group or campaign criteria.", "location": { "fieldPathElements": [ { "fieldName": "operations", "index": 0 }, { "fieldName": "create" }, { "fieldName": "gender" } ] } } ], "requestId": "KN8B8oZZ-M5KeeoE8J5ESQ" } ] } }
--------------------------
Best regards,
John

Google Ads API Forum Advisor

unread,
Aug 25, 2023, 6:13:00 AM8/25/23
to johnzh...@gmail.com, adwor...@googlegroups.com

Hi John,

Thank you for getting back to us.

It appears that you have encountered criterion errors. With regards to "INVALID_USER_INTEREST" error, please note that as stated in this guide (see UserInterestInfo), when retrieving UserInterest to set in UserInterestInfo, verify the availabilities[] are compatible with the campaign type. Some UserInterest options are only available for specific campaign types. With this, kindly consider this recommendation before setting the USER_INTEREST. 

Additionally, regarding the "FIELD_INCOMPATIBLE_WITH_NEGATIVE_TARGETING", this error indicates that the field is not allowed to be set when the negative field is set to true, for example, we don't allow bids in negative ad group or campaign criteria. 

That said, could you provide us with the complete API logs (request and response with request-id and request headergenerated on your end? This is so we could further investigate and provide more appropriate guidance.

If you haven't enabled the logging yet, for REST interface requests, you can enable logging via the curl command by using the -i flag.

Reference Links:

zhang john

unread,
Aug 27, 2023, 9:28:40 PM8/27/23
to Google Ads API and AdWords API Forum
Hi There!

The request-id  was already provided in my previous message. You can get it so easily if you read it carefully.

Best regards,
John

Google Ads API Forum Advisor

unread,
Aug 29, 2023, 11:32:11 AM8/29/23
to johnzh...@gmail.com, adwor...@googlegroups.com

Hi John,

Thanks for getting back to us.

However, aside from the request-id, kindly note we will be needing the complete API logs (request and response with request-id and request header) in this format in order for us to check if there were any issues from your API request that caused the errors you encountered. 

Reference links included in this email:

YETIC SAS

unread,
Sep 11, 2023, 9:37:24 AM9/11/23
to Google Ads API and AdWords API Forum
Hello world,

I have the same issue than John. Below I pasted the logs of one of the request which failed. Thanks in advance for you help, we are really blocked by all the issues related to campaignCriteria and adGroupCriteria :

REQUEST

REQUEST HEADER
{
"request-id": "jA0A1Yxxzv3aHojjMbWZXw",
"developer-token": "hidden",
"customerId": 9115134537,
"login-customer-id": 4712691600,
"Authorization": "Bearer ....."
}

REQUEST BODY
{
"operations": [
{
"create": {
"campaign": "customers/9115134537/campaigns/20532740378",
"bid_modifier": 1,
"gender": {
"type": "MALE"
}
}
}
]
}

RESPONSE
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"errors": [
{
"errorCode": {
"criterionError": "FIELD_INCOMPATIBLE_WITH_NEGATIVE_TARGETING"
},
"message": "The field is not allowed to be set when the negative field is set to true, for example, we don't allow bids in negative ad group or campaign criteria.",
"location": {
"fieldPathElements": [
{
"fieldName": "operations",
"index": 0
},
{
"fieldName": "create"
},
{
"fieldName": "gender"
}
]
}
}
],
"requestId": "jA0A1Yxxzv3aHojjMbWZXw"
}
]
}
}

Thanks in advance,

Best,

Google Ads API Forum Advisor

unread,
Sep 11, 2023, 2:53:21 PM9/11/23
to dev....@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for coming back to us and for providing additional information. I hope you are doing well today.

As mentioned before the error, FIELD_INCOMPATIBLE_WITH_NEGATIVE_TARGETING means that the field is not allowed to be set when the negative field is set to true, for example, we don't allow bids in negative ad group or campaign criteria. That being said, please note that if the ‘negative’ field is set as ‘false’, we are creating positive / standard keywords. Refer to the KeywordsInfo section in the Campaign Criteria documentation, which states you can only exclude keywords at the campaign level.

Thus, the API request call worked and created a negative keyword when the negative field was set to ‘TRUE’ and you received an error when the negative field was set to ‘FALSE’. The field is not allowed to be set when the negative field is set to true, e.g. we don't allow bids in negative Adgroup or campaigns like what I said earlier. Let me know if you have further questions.

In your case, since you didn’t set any, kindly note that if you are using the gender or userlist it needs to explicitly set "negative" to true. With that, could you please try to add “negative”: “true” on your query, like shown below?
 

 "operations": [

    {

      "create": {

        "campaign": "customers/9115134537/campaigns/20532740378",

        “negative”: “true”,

        "bid_modifier": 1,

        "gender": {

          "type": "MALE"

        }

      }

    }

  ]

}

Let us know how it goes on your end.

Have a great day.
 

YETIC SAS

unread,
Sep 12, 2023, 2:05:36 AM9/12/23
to Google Ads API and AdWords API Forum
Thanks a lot, it works well with {"negative": true}  :-). 

Have a great day 

Reply all
Reply to author
Forward
0 new messages