public IEnumerable<Campaign> GetAdCampigns()
{
AdWordsUser user = new AdWordsUser(new AdWordsAppConfig()
{
DeveloperToken = "MyDeveloperToken",
OAuth2ClientId = "MyAccountClientId",
OAuth2ClientSecret = "MyAccountSecret",
OAuth2Mode = OAuth2Flow.APPLICATION,
ClientCustomerId = "MyClientCustomerId",
OAuth2RefreshToken = "MyOAuth2RefreshToken",
UserAgent = "microsoft-socialinsights:ReportDownloader:V3.2"
});
List<Campaign> campaigns = new List<Campaign>();
using (CampaignService campaignService = (CampaignService)user.GetService(AdWordsService.v201809.CampaignService))
{
Selector selector = new Selector()
{
fields = new string[]
{
Campaign.Fields.Id,
Campaign.Fields.Name,
Campaign.Fields.StartDate,
Campaign.Fields.EndDate
},
paging = Paging.Default
};
CampaignPage page = new CampaignPage();
try
{
do
{
// Get the campaigns.
page = campaignService.get(selector);
// Display the results.
if (page?.entries != null)
{
campaigns.AddRange(page.entries);
}
selector.paging.IncreaseOffset();
} while (selector.paging.startIndex < page.totalNumEntries);
}
catch (Exception e)
{
throw new System.ApplicationException("Failed to retrieve campaigns by ids", e);
}
}
return campaigns;
}
POST https://adwords.google.com/api/adwords/cm/v201809/CampaignService HTTP/1.1
Cache-Control: no-cache, max-age=0
Authorization: Bearer ThisisMyBearer__uhmvtn_vUwhIE_4fLLfJLE4d3PFGFwg
Accept-Encoding: gzip, deflate, gzip, deflate
Request-Id: |302c1af313c1814f8aa71dfcf6376b0b.a9568c1c_4.
Content-Type: text/xml; charset=utf-8
Content-Length: 824
Host: adwords.google.com
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<RequestHeader xmlns="https://adwords.google.com/api/adwords/cm/v201809">
<clientCustomerId>594-834-3247</clientCustomerId>
<developerToken>MyDeveloperToken__EaiBWNDw8W6A</developerToken>
<userAgent>microsoft-socialinsights:ReportDownloader:V3.2 (AwApi-DotNet/24.7.0, Common-Dotnet/9.5.0, .NET CLR/4.0.30319.42000, , gzip)</userAgent>
</RequestHeader>
</s:Header>
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<get xmlns="https://adwords.google.com/api/adwords/cm/v201809">
<serviceSelector>
<fields>Id</fields>
<fields>Name</fields>
<fields>StartDate</fields>
<fields>EndDate</fields>
<paging>
<startIndex>0</startIndex>
<numberResults>500</numberResults>
</paging>
</serviceSelector>
</get>
</s:Body>
</s:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201809">
<requestId>00058e05935762030a374e58980e9328</requestId>
<serviceName>CampaignService</serviceName>
<methodName>get</methodName>
<operations>1</operations>
<responseTime>160</responseTime>
</ResponseHeader>
</soap:Header>
<soap:Body>
<getResponse xmlns="https://adwords.google.com/api/adwords/cm/v201809">
<rval>
<totalNumEntries>0</totalNumEntries>
<Page.Type>CampaignPage</Page.Type>
</rval>
</getResponse>
</soap:Body>
</soap:Envelope>The following campaign types are available in the UI but are not currently supported in the API:
Hi Rafael,
My apologies for the inconvenience.
You are correct that the video campaign is currently not supported in any AdWords services and this is the reason why you got empty result using the CampaignService.
Please continue to follow our blog to receive future updates and new releases.
Thanks and regards,
Ejay
Google Ads API Team