Here's my Java code in order to extract data from Adobe Analytics: (cloned from GitHub repository)
public static AnalyticsClient SecretAuthentication(String endpoint,String username,String password){
AnalyticsClient client = new AnalyticsClientBuilder()
.setEndpoint(endpoint)
.authenticateWithSecret(username, password)
.build();
return client;
}
public static void main(String[] args) throws IOException, InterruptedException{
AnalyticsClient client = SecretAuthentication("api.omniture.com","username","my_secret_pass");
ReportDescription desc = new ReportDescription();
String rsid="my_rs_id";
desc.setReportSuiteID(rsid);
desc.setDateFrom("2016-10-12"); // YYYY-MM-DD
desc.setDateTo("2016-10-13");
desc.setMetricIds("entries","orders","pageviews","visits","visitors");
String[] elements = new String[2];
elements[0]="prop3";
elements[1]="prop33";
desc.setElementIds(elements);
//Pass the description to the API queue method, which will start the process of preparing the report:
ReportMethods reportMethods = new ReportMethods(client);
int reportId = reportMethods.queue(desc);
System.out.println(reportId);
//The received integer is a report id, which can be used to receive the actual report using the get() method.
//Preparing report takes some time, and the get() method will throw an exception with appropriate message if the report is not ready yet.
//Following code runs the get() method in a loop, waiting until the report is ready:
ReportResponse response = null;
while (response == null) {
try {
response = reportMethods.get(reportId);
//System.out.println(response.toString());
} catch (ApiException e) {
System.out.println(e.toString());
Thread.sleep(3000);
continue;
}
}
List<ReportData> responseData = response.getReport().getData();
System.out.println("Is there data in the report? "+responseData.size());
for (int j = 0; j < responseData.size(); j++)
{
System.out.println(responseData.get(j).getName()+ " has :");
System.out.println(responseData.get(j).getCounts());
}
}
An example output of the last "for" statement is:
FR has :
[35732.0, 0.0, 115146.0, 36402.0, 32111.0]
The 5-sized vector includes the metric values ("entries","orders","pageviews","visits","visitors") The "FR" (France) is the value of the first element (prop3) which is actually the "Country" variable. The problem is that I have no information about the second element, prop33 (prop33 is "Device Type").
String[] elements = new String[2];
elements[0]="prop3";
elements[1]="prop33";
The most important is that Adobe seems to ignore the second element (prop33) and considers only the first one (prop3) for its search. I can prove this by changing the order of the two elements in elements array.
String[] elements = new String[2];
elements[0]="prop33";
elements[1]="prop3";
If I place prop33 first the output lines are different and Adobe responds as if prop33(Device Type) were the only criterion. For example:
iPhone has :
[47636.0, 6.0, 107440.0, 47729.0, 42330.0]
So, how can I send two or more elements as a matching criterion??
This isn't an answer more of a response to your last comment that's too long for a comment that should hopefully help you figure out what the problem is. Again disclaimer that I'm not an actual java coder so take that for what it's worth. But..
Firstly, just to be clear, you did try this, right?
desc.setElementIds("prop3", "prop33");
And you say that doesn't work? Because looking at
setElementIds
I seepublic void setElementIds(String... elementIds) { .. }
My 5 minute understanding of java is
String...
is basically syntactic sugar forString[]
(array) but it's to accept the strings as multiple arguments passed, not a single array of strings, so it looks to me that passing multiple args is indeed the way to go.But overall you should check what is actually being sent to Adobe in the request. I expect the requirements are similar for the soap/xml version, but I don't know really know the soap/xml version so here's the JSON version. Based on what you posted (
Report.Queue
) JSON object payload hould look like this:So check the http(s) request to make sure it looks like that (or soap/xml equiv).
And your (JSON) response (
Report.Get
) should look something like this: