language: java 1.8
IDE: eclipse
using Google Cloud Platform App Engine
I want get all campaigns in my account, so I tried
com.google.api.ads.adwords.axis.v201809.cm.CampainServiceInterface's get()
method.
But I received "No campaigns were found", even I had campaigns.
Moreover, when I use
com.google.api.ads.adwords.axis.v201809.cm.ReportDefinitionServiceInterface's
getReportFields() method, it brings me correct response.
Please solve this problem.
Under this section, I upload my codes.
AdWordsSession session = null;
CreateAdWordsSessionWithoutPropertiesFile
createAdWordsSessionWithoutPropertiesFile = new
CreateAdWordsSessionWithoutPropertiesFile();
try {
session = createAdWordsSessionWithoutPropertiesFile.createAdWordsSession();
} catch (OAuthException | ValidationException e2) {
e2.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
AdWordsServicesInterface adWordsServices = AdWordsServices.getInstance();
CampaignServiceInterface campaignService = adWordsServices.get(session,
CampaignServiceInterface.class);
System.out.println(campaignService.toString());
int offset = 0;
// Create selector.
SelectorBuilder builder = new SelectorBuilder();
Selector selector = builder
.fields(CampaignField.Id, CampaignField.Name)
.orderAscBy(CampaignField.Name)
.offset(offset)
.limit(100)
.build();
CampaignPage page;
do {
// Get all campaigns.
page = campaignService.get(selector);
if(page == null) {
System.out.println("page is null");
}
System.out.println(page.getPageType());
System.out.println(page.toString());
// Display campaigns.
if (page.getEntries() != null) {
for (Campaign campaign : page.getEntries()) {
System.out.printf("Campaign with name '%s' and ID %d was
found.%n", campaign.getName(), campaign.getId());
}
} else {
System.out.println("No campaigns were found.");
}
offset += 100;
selector = builder.increaseOffsetBy(100).build();
} while (offset < page.getTotalNumEntries());
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/b07d63e6-6fcc-408e-8e11-da115f022dff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.