TargetRestriction missing method "getBidOnlyCase"

22 views
Skip to first unread message

Kate Orlova

unread,
Aug 2, 2021, 1:33:09 PM8/2/21
to AdWords API and Google Ads API Forum
Hi!
I'm receiving campaign.targeting_setting.target_restrictions and then I want to get this list just as json string, but when I call googleAdsRow.getCampaign().getTargetingSetting().getTargetRestrictionsList().toString() I receive an exception Generated message class "com.google.ads.googleads.v7.common.TargetRestriction" missing method "getBidOnlyCase".
Same exception if I get googleAdsRow.getCampaign().getTargetingSetting().getTargetRestrictions(0).toString().

How can I get this values as string?

Google Ads API Forum Advisor

unread,
Aug 2, 2021, 8:41:18 PM8/2/21
to adwor...@googlegroups.com
Hi Kate,

Thanks for bringing this question to our attention. First when looking at this, I would like to ask if you are working on the current version of the API. As you are showing an issue with v7, but all of our documents show v8. If using the lower version we would say to upgrade to 8. Here is the code sample from our documents that we know works and should not have any issues.

Regards,

Google Logo
William Pescherine
Google Ads API Team
 


ref:_00D1U1174p._5004Q2LUMwA:ref

Kate Orlova

unread,
Aug 3, 2021, 4:16:43 PM8/3/21
to AdWords API and Google Ads API Forum
Hi! I've upgrade API to v8, but still have same problem:
Generated message class "com.google.ads.googleads.v8.common.TargetRestriction" missing method "getBidOnlyCase".
You can reproduce this like that:
TargetRestriction.Builder targetRestriction = TargetRestriction.newBuilder();
targetRestriction.setBidOnly(true);
String restrictionJson = targetRestriction.build().toString();

This problem appear not only with TargetRestriction, but with many other entities. Maybe there is another way to transform it to string?

Google Ads API Forum Advisor

unread,
Aug 4, 2021, 1:54:17 PM8/4/21
to adwor...@googlegroups.com
Hi Kate,

Thank you for reaching out to us. Having looked over the post a bit more, we would suggest that you reach out to our Java Implementation team here . They can better help and handle this as it would appear to be an issue with the Java implementation code. Also at the same time if you are looking to convert something to a string in Java just take the variable that you need to turn to a string and add a +"" to it this will change it to a string.

ex.
    int num = 4;
    String word = num +"";
    
    The word is now a string that is "3" and not an int of 3

But we would still advise reaching out to the people on the link.
Reply all
Reply to author
Forward
0 new messages