Hi Sabra,

This works if you follow the steps mentioned in the article. I have done an
app on APPEXCHANGE and Heroku using the same approach.

[1] Worked in my environment.

The issue you are experiencing is that may be due to the session id is not
properly set or invalid.

Therefore it's redirecting you to the salesforce login page (which is a
html page.)

Try setting the session to the header.


[1] https://ap1.salesforce.com/00O9000000214cu?export=1&enc=UTF-8&xf=csv



On Wed, Feb 25, 2015 at 11:19 AM, Sabra Ossen <[email protected]> wrote:

> 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
>
>


-- 

Best Regards,

Malaka Silva
Senior Tech Lead
M: +94 777 219 791
Tel : 94 11 214 5345
Fax :94 11 2145300
Skype : malaka.sampath.silva
LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
Blog : http://mrmalakasilva.blogspot.com/

WSO2, Inc.
lean . enterprise . middleware
http://www.wso2.com/
http://www.wso2.com/about/team/malaka-silva/
<http://wso2.com/about/team/malaka-silva/>

Save a tree -Conserve nature & Save the world for your future. Print this
email only if it is absolutely necessary.
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to