Hi,

My requirement is to obtain a reports' record data through my java
application.

Currently I am following this blog[1] and using the following code section
to get access to the URL and get the csv file.

String authEndPoint = "https://login.salesforce.com/services/Soap/c/33.0";;
String username = "[email protected]";
String password = "xxxxxxxxxx";
String sessionId = "";

try {
   ConnectorConfig config = new ConnectorConfig();
   config.setUsername(username);
   config.setPassword(password);

   config.setAuthEndpoint(authEndPoint);

   sessionId = config.getSessionId();

   String urlString =
"https://na9.salesforce.com/xxxxxxxxxxxxxxx?export=1&enc=UTF-8&xf=csv&sessionId=";
+ sessionId;

   Scanner in = new Scanner((new URL(urlString)).openStream());

   while (in.hasNextLine()){
      System.out.println(in.nextLine());
   }

} catch (MalformedURLException e) {
   e.printStackTrace();
} catch (IOException e) {
   e.printStackTrace();
}

But I get a response of an html file only, not a csv file. When I access
the URL from my browser without the sessionId part it downloads the csv
file.

Is there any better way to get the report data or am I doing this all
wrong. Any help on this situation is appreciated very much.

Thanks.

[1]
http://sfdc-heretic.warped-minds.com/2006/04/10/progmatic-access-to-salesforcecom-reports/

-- 
Sabra Ossen
*Software Engineering Intern*
Mobile : +94 (0) 785 227 769
[email protected]
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to