Srinivasa Reddy

Can you help on this I am trying to get windows contact data using java program and end up with an error 403 Forbidden.
I already get userhandle, DomainAuthenticationToken, RequestApproved information and then trying to open an URL
connection with the uri,

URL u = new URL(uri);
HttpURLConnection uc = (HttpURLConnection) u.openConnection();
uc.setRequestProperty("Authorization", "DomainAuthToken at=\"" + DomainAuthenticationToken + "\"");

System.out.println("property " + uc.getRequestProperty("Authorization"));
PrintWriter pw = new PrintWriter(uc.getOutputStream());

System.out.println("ResponseCode " + uc.getResponseCode());
System.out.println("ResponseMessage " + uc.getResponseMessage());
System.out.println("getContentType " + uc.getContentType());
System.out.println("getContentLength " + uc.getContentLength());

Then here, I am getting ResponseCode as 403 and ResponseMessage as forbidden.
So please let me know the root cause for this or how to get windows contacts using java

Re: 403: Forbidden' for url: ''

Federico Raggi - MSFT

Hi, Srinivasa!

Windows Live Data uses standard HTTP requests and responses to communicate with applications so the language you use should not be a problem as long as it support creating HTTP requests and getting responses back.

I checked your code, and it seems correct. Here are some basic things that comes to mind:

- Are you sending the HTTP GET request from the same domain, and for the same user The Domnain Authentication Token is specific for each domain and user Live ID.

- The Authorization header should be something like this:

Authorization: DomainAuthToken at=""

Note that the above header is a single line.

Let me know if any of this helps. If not, I'll try to create a Java program to see how it works.

Re: 403: Forbidden' for url: ''

Federico Raggi - MSFT

One last thing, could you try without the trailing slash on the uri:

instead of

Re: 403: Forbidden' for url: ''

Srinivasa Reddy

Hi Federico,

Thank you very much for your timely help. I am able to get contacts information now. There was a problem in my code in preparing authentication token and I commented some of the code related to printwriter as I really don't require PrintWriter(uc.getOutputStream());

but i have added

BufferedReader in = new BufferedReader( new InputStreamReader(uc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {

thanks once again