>
> Hi Thanks for the quick response.

1. We access_token i have been getting the right way itself, which is 
recommended by the AdwordsApi document   
https://developers.google.com/adwords/api/docs/guides/authentication . I am 
using the test developer token, is that an issue ?
2. Regarding the request which i am sending as soap , i created myself, 
because i didn't find any relevant exmaple in the document for Report one. 
The XML structured input i replicated all the fields from the document 
https://developers.google.com/adwords/api/docs/guides/reporting 
3. Regarding java client example , i have used that as well but i get error 
out there as well:

Exception in thread "main" java.lang.NoClassDefFoundError: 
com/google/inject/Module
at 
com.google.api.ads.adwords.lib.utils.AdWordsInternals.<clinit>(AdWordsInternals.java:37)
at 
com.google.api.ads.common.lib.auth.OfflineCredentials$Api.getInternals(OfflineCredentials.java:107)
at 
com.google.api.ads.common.lib.auth.OfflineCredentials$Builder.defaultOptionals(OfflineCredentials.java:318)
at 
com.google.api.ads.common.lib.auth.OfflineCredentials$Builder.forApi(OfflineCredentials.java:312)
at com.googleAnalatics.google.AdWordsApi.main(AdWordsApi.java:40)
Caused by: java.lang.ClassNotFoundException: com.google.inject.Module
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)   


I have been using the below  code just the file location i have changed and 
added the input within : Please find the code. May i know what is the issue 
here, why i am getting above error while running.

import com.google.api.ads.adwords.axis.factory.AdWordsServices;
import com.google.api.ads.adwords.lib.client.AdWordsSession;
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration;
import com.google.api.ads.adwords.lib.factory.AdWordsServicesInterface;
import com.google.api.ads.adwords.lib.utils.ReportDownloadResponseException;
import com.google.api.ads.adwords.lib.utils.ReportException;
import com.google.api.ads.common.lib.auth.OfflineCredentials;
import com.google.api.ads.common.lib.exception.OAuthException;
import com.google.api.ads.common.lib.exception.ValidationException;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.ads.adwords.lib.jaxb.v201809.DownloadFormat;
import com.google.api.ads.adwords.lib.jaxb.v201809.ReportDefinition;
import 
com.google.api.ads.adwords.lib.jaxb.v201809.ReportDefinitionDateRangeType;
import com.google.api.ads.adwords.lib.jaxb.v201809.ReportDefinitionReportType;
import com.google.api.ads.adwords.lib.jaxb.v201809.Selector;
import com.google.api.ads.adwords.lib.utils.ReportDownloadResponse;
import com.google.api.ads.adwords.lib.utils.v201809.ReportDownloaderInterface;

import java.io.IOException;
import java.util.Arrays;

public class AdWordsApi {

   
    public static void main(String[] args) {
        System.getProperties().setProperty("https.proxyHost", 
"gate-zrh-os.swissre.com");
        System.getProperties().setProperty("https.proxyPort", "8080");

        AdWordsSession session;
        try {
            Credential oAuth2Credential =
                    new OfflineCredentials.Builder()
                            .forApi(OfflineCredentials.Api.ADWORDS)
                            .withClientSecrets(CLIENT_ID, CLIENT_SECERT)
                            .withRefreshToken(REFRESH_TOKEN)
                            .build()
                            .generateCredential();

            session =
                    new 
AdWordsSession.Builder().withDeveloperToken(DEVELOPER_TOKEN).withClientCustomerId(CUSTOMER_ID).withOAuth2Credential(oAuth2Credential).build();

            AdWordsServicesInterface adWordsServices = 
AdWordsServices.getInstance();
            String reportFile = "Ad_Report" + ".csv";

            runExample(adWordsServices, session, reportFile);

        } catch (OAuthException e) {
            e.printStackTrace();
        } catch (ValidationException e) {
            e.printStackTrace();
        } catch (ReportException e) {
            e.printStackTrace();
        } catch (ReportDownloadResponseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void runExample(AdWordsServicesInterface adWordsServices, 
AdWordsSession session, String reportFile) throws IOException, 
ReportDownloadResponseException, ReportException {

        Selector selector = new Selector();
        selector.getFields().addAll(Arrays.asList("CampaignId",
                "AdGroupId",
                "CampaignName",
                "CampaignId",
                "Criteria",
                "FinalUrls",
                "Impressions",
                "Clicks",
                "Cost"));

        ReportDefinition reportDefinition = new ReportDefinition();
        reportDefinition.setReportName("Criteria performance report #" + 
System.currentTimeMillis());
        
reportDefinition.setDateRangeType(ReportDefinitionDateRangeType.LAST_30_DAYS);
        
reportDefinition.setReportType(ReportDefinitionReportType.AD_PERFORMANCE_REPORT);
        reportDefinition.setDownloadFormat(DownloadFormat.CSV);

        // Optional: Set the reporting configuration of the session to suppress 
header, column name, or
        // summary rows in the report output. You can also configure this via 
your ads.properties
        // configuration file. See AdWordsSession.Builder.from(Configuration) 
for details.
        // In addition, you can set whether you want to explicitly include or 
exclude zero impression
        // rows.
        ReportingConfiguration reportingConfiguration =
                new ReportingConfiguration.Builder()
                        .skipReportHeader(false)
                        .skipColumnHeader(false)
                        .skipReportSummary(false)
                        .includeZeroImpressions(false)
                        .build();
        session.setReportingConfiguration(reportingConfiguration);

        reportDefinition.setSelector(selector);

        ReportDownloaderInterface reportDownloader =
                adWordsServices.getUtility(session, 
ReportDownloaderInterface.class);

        ReportDownloadResponse response = 
reportDownloader.downloadReport(reportDefinition);
        response.saveToFile(reportFile);

        System.out.printf("Report successfully downloaded to: %s%n", 
reportFile);
    }
}



-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/8d377b1d-8cb1-4133-97ed-5f877d3f51ea%40googlegroups.com.

Reply via email to