Hi Chandra, I'm thinking this issue is related to the lack of an Authorization header and the wrong HTTP method on the request that's made in response to the 302 redirect. You may wish to take a look at how the Java client lib source to see how it does this [1].
To test this hypothesis, try taking the URL you're getting redirected to (the one with the gsessionid in it) and plugging it into the line you use to construct the URL-- see if you still get this error. You could also try and do a packet capture and look at the traffic. I suspect you'll see: 1) POST http://www.google.com/calendar/feeds/default/private/full responding with a 302 redirect. The location header will have a gsessionid in it. Your request will have an authorization header in it as well, as you manually added it in your code. 2) GET http://www.google.com/calendar/feeds/default/private/full responding with a 401 forbidden. The request will not include the authorization header as it probably wasn't set when doing the redirect follow up request. To avoid the GET instead of the POST in step #2, use: System.setProperty("http.strictPostRedirect", "true"); You may also want to set: googleDefaultURLCon.setInstanceFollowRedirects(true); Or.. you could always use the Java client library for GData -- this is all handled in that library :) Cheers, -Ryan [1] - http://gdata-java-client.googlecode.com/svn/trunk/java/src/com/google/gdata/client/http/HttpGDataRequest.java On Apr 4, 11:12 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi Ryan, > I changed the URL to "http://www.google.com/calendar/feeds/default/ > private/full " , still I am getting the same exception. I tried to > replace the default in URL with my gmail ID and with my "name" also > but still I am facing the same problem. Do I have to replace default > with something else such as Calendar name or Calendar ID if there > exists any. > > Exception: > Exception in thread "main" java.io.IOException: Server returned HTTP > response code: 401 for > URL:http://www.google.com/calendar/feeds/default/private/full?gsessionid=... > > at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown > Source) > > at QuickAddTest.main(QuickAddTest.java:94) > > Thank you, > > Chandra Sekhar > > On Apr 3, 4:50 pm, "Ryan Boyd (Google)" <[EMAIL PROTECTED]> wrote: > > > Hi Chandra, > > > You should post to the 'full' visibility feed instead of the 'basic' > > visibility feed. The basic feed is read-only > > > See the following documentation for more > > info:http://code.google.com/apis/calendar/reference.html#Visibility > > > Cheers, > > > -Ryan > > > On Apr 3, 10:50 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > wrote: > > > > Hi Edurado, > > > > I saw your posting on the forum about the Google Quick add > > > functionality. I just have a small doubt. Which URL do you post the > > > quick-add XML (atom) data to. I did the authentication and I am > > > getting the auth Token, now I am trying to set the developer key and > > > posting it tohttp://www.google.com/calendar/feeds/default/private/basic. > > > But I am > > > getting a 401 error on the URL. If you remember the URL or any > > > problems that you think i have, could you please send me the link. > > > Below is the snippet. > > > > RL googleDefaultURL = new URL("http://www.google.com/calendar/feeds/ > > > default/private/basic"); > > > > HttpURLConnection googleDefaultURLCon = > > > (HttpURLConnection)googleDefaultURL.openConnection(); > > > > googleDefaultURLCon.setDoInput(true); > > > > googleDefaultURLCon.setDoOutput(true); > > > > googleDefaultURLCon.setUseCaches(false); > > > > googleDefaultURLCon.setRequestMethod("POST"); > > > > googleDefaultURLCon.setRequestProperty("Content-Type", "application/ > > > atom+xml"); > > > > //googleDefaultURLCon.setRequestProperty( "User-Agent", "Mozilla/4.0 > > > (compatible; MSIE 5.5; Windows NT 5.0; H010818)"); > > > > googleDefaultURLCon.setRequestProperty("Authorization", "GoogleLogin > > > auth=" + authToken); > > > > googleDefaultURLCon.setRequestProperty("X-Google-Key", "key=" + > > > developerKey); > > > > DataOutputStream googleOutputStream = new > > > DataOutputStream(googleDefaultURLCon.getOutputStream()); > > > > DataInputStream googleInputStream = new > > > DataInputStream(googleDefaultURLCon.getInputStream()); > > > > String quickAddData_String = "<?xml version=\'1.0\'?>\n" + > > > > "<atom:entry xmlns:atom='http://www.w3.org/2005/Atom'>\n" + > > > > "<atom:category scheme='http://schemas.google.com/g/2005#kind'" + > > > > "term='http://schemas.google.com/g/2005#event'></atom:category>\n" + > > > > "<atom:content type='text'>meeting at university of virginia tomorrow > > > 8am</atom:content>\n" + > > > > "<gCal:quickadd xmlns:gCal='http://schemas.google.com/gCal/2005'" + > > > > "value='true'></gCal:quickadd>\n</atom:entry>"; > > > > byte[] quickAddData_bytes = quickAddData_String.getBytes(); > > > > googleOutputStream.write(quickAddData_bytes); > > > > googleOutputStream.close(); > > > > System.out.println(googleInputStream.readLine()); > > > > googleInputStream.close(); > > > > And the error I get is > > > > Exception in thread "main" java.io.IOException: Server returned HTTP > > > response code: 401 for > > > URL:http://www.google.com/calendar/feeds/default/private/basic?gsessionid... > > > > at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown > > > Source) > > > > at QuickAddTest.main(QuickAddTest.java:94) > > > > Thank you, > > > > Chandra Sekhar > > > > On Mar 13, 9:45 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > > wrote: > > > > > Thanks so much!- Hide quoted text - > > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Calendar Data API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-calendar-help-dataapi?hl=en -~----------~----~----~----~------~----~------~--~---
