Hello Trevor, thanks for your reply. Meanwhile I read the calendar API a few more times and got attentive to the following part:
>Just like in the previous example, Calendar may return an HTTP 302 redirect; >if so, then the redirect URL has a new >parameter, gsessionid, appended to it. >If you received the redirect, then send the same POST request again, with the >>same Authorization header and the same content, but with the gsessionid >parameter appended. As I looked around in the group I found this thread: >http://groups.google.com/group/google-calendar-help-dataapi/browse_thread/thread/6f96fba5e1013af5/14d07e5164d3921a?lnk=gst&q=java+401+error#14d07e5164d3921a I did like advised and set a system property: >System.setProperty("http.strictPostRedirect", "true"); now it works fine. Sorry if I wasted your time, I should have posted a message that I found a solution. Martin Staudigel On Jan 7, 3:05 am, Trevor Johns <[email protected]> wrote: > On Thu, Jan 1, 2009 at 2:52 AM, Martin St. <[email protected]> wrote: > > > Hello all, > > I try to create an event using ClientLogin like explained in the API > > developers guide. > > I succeed in receiving the auth token, but when I try to post the > > calendar-event I receive an 401-Error. What I do is: > > <code> > > URL url = new URL("http://www.google.com/calendar/feeds/default/ > > private/full"); > > HttpURLConnection con = (HttpURLConnection) url.openConnection(); > > con.setRequestProperty("CONTENT-TYPE", "application/atom+xml"); > > con.setRequestProperty("Authorization", "GoogleLogin > > "+this._authToken); > > con.setRequestMethod("POST"); > > con.setDoOutput(true); > > OutputStreamWriter oswr = new OutputStreamWriter(con.getOutputStream > > ()); > > oswr.write(this._calendarEntry); > > oswr.flush(); > > </code> > > > this._authToken ist the token I received from "https://www.google.com/ > > accounts/ClientLogin" > > this._calendarEntry is the calendar entry as described in the dev- > > guide. > > > Here is an example for the response: > > Server returned HTTP response code: 401 for URL: > >http://www.google.com/calendar/feeds/default/private/full?gsessionid=... > > > Has anybody an idea what goes wrong? > > > Thanks, > > Martin > > Martin, > Can you provide a sample of how you're requesting the ClientLogin > token? Specifically, can you make sure that you're using 'cl' as the > service name? > > -- > Trevor Johns --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
