Hi,
I have build a small Maven project to run a query within Report Central and pull the report via the "DoubleClick for Advertisers API" (
https://developers.google.com/doubleclick-advertisers/docs/reference/v1.20).
I have received a test account from my client and I can log into DoubleClick for Advertisers as well as in Report Central. I have created a sample query in RC (ID 7421025) and am now trying to get the report data from it.
I have put a properties file with the following content into the "src/main/resources" directory:
api.dfa.username=...
api.dfa.password=...
api.dfa.applicationName=DFA Exporter
api.dfa.environment=production
report.queryId=7421025I use the same user name and password which I use to log into DC for Advertisers and RC. Here is the SOAP request and the response:
[
WARN] soapXmlLogger - SOAP Request:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:RequestHeader xmlns:ns1="http://www.doubleclick.net/dfa-api" soapenv:mustUnderstand="0">
<ns1:applicationName mustUnderstand="0" actor="">DFA Exporter (DfaApi-Java, Dfa-Axis/1.18.1, Common-Java/1.18.1, Axis/1.4, Java/1.6.0_51, maven)</ns1:applicationName>
</ns1:RequestHeader>
</soapenv:Header>
<soapenv:Body>
<ns2:authenticate xmlns:ns2="http://www.doubleclick.net/dfa-api/v1.20" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<username xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string">...</username>
<password xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string">...</password>
</ns2:authenticate>
</soapenv:Body>
</soapenv:Envelope>
[WARN] soapXmlLogger - SOAP Response:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>4 - Invalid username or password.</faultstring>
<detail>
<com.google.ads.xfa.soapapi.entity.common.ApiException xmlns:ns1="http://www.doubleclick.net/dfa-api/v1.20" xsi:type="ns1:ApiException">
<errorCode xsi:type="xsd:long">4</errorCode>
<errorMessage xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string">Invalid username or password.</errorMessage>
<message xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string">Invalid username or password.</message>
</com.google.ads.xfa.soapapi.entity.common.ApiException>
<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">yhjp69</ns2:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>The username and password is picked up properly from the properties file, but it seems to be invalid. There are a couple of obvious reasons for this and I hope that someone can help me in the right direction:
- Is it correct that I am using the same account which I use for the UI and RC?
- If not, do I need a special account for the API?
- If yes, is the account not activated for the API?
- Do I need to ask the client to do this?
- Is there anything else that I am missing?
Just for the sake of completeness, here is my code:
/* Load configuration */
Configuration config = new PropertiesConfiguration(options.valueOf("config").toString());
/* Create session and report service */
DfaSession session = new DfaSession.Builder().from(config).build();
ReportRemote reports = new DfaServices().get(session, ReportRemote.class);
/* Run query */
System.out.println("Running query with id " + config.getLong("report.queryId"));
ReportRequest request = new ReportRequest();
request.setQueryId(config.getLong("report.queryId"));
ReportInfo info = reports.runDeferredReport(request);
System.out.println("Waiting for report with id " + info.getReportId());
request.setReportId(info.getReportId());
/* Check report status every X seconds */
while (info.getStatus().getId() == PENDING || info.getStatus().getId() == RUNNING) {
System.out.println("Got status " + info.getStatus().getName() + "; waiting another round");
Thread.sleep(SECS_TO_WAIT * 1000);
info = reports.getReport(request);
}
System.out.println("Final status " + info.getStatus().getName());
/* Bail out if we have found an error */
if (info.getStatus().getId() == ERROR) {
throw new Exception("Report generation failed");
}
/* Download report*/
String output = options.valueOf("output").toString();
System.out.println("Saving report to " + output);
HttpUtils.downloadFile(info.getUrl(), output);
Thanks, Tobias.