How to get campaign with all elements (adGroups, ads) after mutate?

18 views
Skip to first unread message

Zied Chaari

unread,
May 10, 2019, 5:00:08 AM5/10/19
to AdWords API and Google Ads API Forum
Hi All,

Is there a way to get campaign with all their elements (adGroup, ads) after performing a Mutate action?
I asked this question, because a want to get AdGroup and Ads status after updating campaign status.
I'm using Google AdWords API. You can find bellow my piece of code.

using (Google.Api.Ads.AdWords.v201809.CampaignService campaignService = (Google.Api.Ads.AdWords.v201809.CampaignService)user.GetService(AdWordsService.v201809.CampaignService))
            {
                Google.Api.Ads.AdWords.v201809.Campaign campaign = new Google.Api.Ads.AdWords.v201809.Campaign
                {
                    id = campaignId,
                    status = CampaignStatus.ENABLED
                };
                Google.Api.Ads.AdWords.v201809.CampaignOperation operation = new Google.Api.Ads.AdWords.v201809.CampaignOperation
                {
                    operand = campaign,
                    @operator = Operator.SET
                };
                try
                {
                    CampaignReturnValue retVal = campaignService.mutate(new Google.Api.Ads.AdWords.v201809.CampaignOperation[]
                    {
                        operation
                    });
                    AddAPILog(SocialMedia.Google, "ActiveCampaign", "", campaign, retVal, "PUT", "ActiveCampaign", user.Config.OAuth2RefreshToken, null, true);
                    return true;
                }
                catch (Exception e)
                {
                    AddAPILog(SocialMedia.Google, "ActiveCampaign", "", campaign, "", "PUT", "ActiveCampaign", user.Config.OAuth2RefreshToken, null, true);
                    return false;
                }
            }

Thanks,
Zied 

googleadsapi...@google.com

unread,
May 10, 2019, 10:51:18 AM5/10/19
to acteol...@gmail.com, AdWords API and Google Ads API Forum
Hello Zied, 

The API services will return data for any specific level and it is not possible to get the AdGroupStatus while mutating a campaign. You will need to make another API call to AdGroupService.get() to get the status. One other option is to use the Ad Performance Report which will return the specific status for the ad, ad group and campaign. 

Let me know if you have any questions.

Regards,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Reply all
Reply to author
Forward
0 new messages