Thanks Austin. That helped me.

Regards
Rainbow

On Nov 7, 1:33 pm, "Austin (Google)" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> GData server sometimes redirect syour request with a 302.  It's not
> enough to just follow redirection by calling setFollowRedirects() with
> HttpUrlConnection, because it doesn't append the necessary auth token
> in the redirect header.  You need to rebuild the redirect request with
> auth token in the header again.
>
> You should check out our Java GData client library, it automatically
> handles redirection gracefully and very easy to use.  You may download
> it from here:
>
> http://code.google.com/p/gdata-java-client/downloads/list
>
> Hope that helps,
> Austin
>
> On Nov 6, 9:30 pm, rainbow <[EMAIL PROTECTED]> wrote:
>
>
>
> > Dear All,
>
> > I am getting 401 error while adding a quick entry into google database
> > as explained in protocol guide.
>
> > But I could successfully get auth token and even get the calendar
> > entry feeds based on query parameters. Only problem is while trying to
> > create a new quick entry.
>
> > The following is the sample code with which I am trying to do. Can
> > anyone please help me where is problem.
>
> > Thanks & Regards
> > rainbow
>
> > sample code:
> > -----------------------------------------------------------
> > ttpURLConnection urlConnection = null;
> >                 try {
> >                         urlConnection = (HttpURLConnection )new 
> > URL("http://www.google.com/
> > calendar/feeds/default/private/full").openConnection();
> >                 } catch (MalformedURLException e) {
> >                         e.printStackTrace();
> >                 } catch (IOException e) {
> >                         e.printStackTrace();
> >                 }
> >                 try {
> >                         urlConnection.setRequestMethod("POST");
> >                 } catch (ProtocolException e) {
> >                         e.printStackTrace();
> >                 }
>
> >                 urlConnection.setRequestProperty("Authorization", 
> > "GoogleLogin
> > auth="+authToken);
> >                 urlConnection.setRequestProperty("Content-Type", 
> > "application/atom
> > +xml");
> >                 urlConnection.setRequestProperty("Content-Length", "5000");
> >                 System.out.println("Opening output stream..");
> >                 int responseCode = -1;
> >                 try {
> >         urlConnection.setDoOutput(true);
> >         urlConnection.setDoInput(true);
> >         OutputStream outputStream = urlConnection.getOutputStream();
> >         outputStream.write(buf.toString().getBytes());
> >         outputStream.close();
> >              // Retrieve the output
> >              responseCode = urlConnection.getResponseCode();
> >              InputStream inputStream;
> >              if (responseCode == HttpURLConnection.HTTP_CREATED) {
> >       inputStream = urlConnection.getInputStream();
> >         System.out.println("Success..");
> >      } else {
> >       inputStream = urlConnection.getErrorStream();
> >       System.out.println("Failure.." + responseCode);
> >      }
> > --------------------------------------------------------- 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to