How to get the Entire Campaign object when creating the campaign

243 views
Skip to first unread message

Wayne

unread,
Jan 11, 2022, 12:45:52 PM1/11/22
to Google Ads API and AdWords API Forum
Hi!
Hope you're doing well.

I have a question.
When I am creating campaign like this

MutateCampaignsResponse response = campaignServiceClient.mutateCampaigns( customerId, operations);
for (MutateCampaignResult result : response.getResultsList()) {
String createdCampaign = result.getResourceName();
}

Since "result" only contains the resource name, I am only able to get the resource name of the newly created campaign! Is there any way to fetch the entire Campaign object which was created on Google? (Without any GET call/ query)

Thanks.

Google Ads API Forum Advisor

unread,
Jan 11, 2022, 3:04:17 PM1/11/22
to cos.squa...@gmail.com, adwor...@googlegroups.com
Hi Wayne,

Thanks for reaching out. To fetch the entire campaign object with all of its attributes, you must issue a GET request.

You can create a campaign object, referencing an existing campaign with: 

      Campaign campaign =
          Campaign.newBuilder()
              .setResourceName(ResourceNames.campaign(customerId, campaignId))

Regards,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 


ref:_00D1U1174p._5004Q2UinQf:ref

Wayne

unread,
Jan 12, 2022, 6:17:05 AM1/12/22
to Google Ads API and AdWords API Forum
Thanks Matt for the quick response there!

I had a doubt, wouldn't GET request be a not-so-good idea, since there is a limit on GET requests(1000/day)? Further we don't want to make any external Google API call.
All we need is the campaign ID from the resource name! Is there a function for that without making a GET / Search request ? This would be quite helpful since we can't change the Database schema at our end. All primary keys are campaign ID, adgroup ID and so on... We can't change it to campaign resource name or adgroup resource name. Please help us in figuring out how to extract the campaign ID from the resource name WITHOUT making an API call to Google!

Help would be appreciated. Thanks!

Google Ads API Forum Advisor

unread,
Jan 12, 2022, 5:35:35 PM1/12/22
to cos.squa...@gmail.com, adwor...@googlegroups.com
Hi Wayne,

You can make a MutateCampaignsRequest and set the response_content_type field to MUTABLE_RESOURCE. This determines whether the mutable resource or just the resource name should be returned post mutation. Please see this example of its usage.

Alternatively, if you have the resource name just need the campaign ID, you can simply strip that last parameter from the resource name, customers/{customer_id}/campaigns/{campaign_id}. 

Wayne

unread,
Jan 13, 2022, 5:25:14 AM1/13/22
to Google Ads API and AdWords API Forum
Amazing! That helped. Thanks a lot! :)
Reply all
Reply to author
Forward
0 new messages