Hello Bruno, Is there any reason why you cannot use the Java GData client library<http://code.google.com/apis/calendar/data/2.0/developers_guide_java.html>to consume the Google Calendar API?
This should make your life much more easier than having to set-up an http connection manually and write the raw XML document. In your case, this looks like you are not sending the event entry to the correct feed URL which should be: https://www.google.com/calendar/feeds/default/private/full for the user's primary calendar. Best, Alain On Fri, Jul 22, 2011 at 1:17 PM, Bruno Baudel <brunobau...@gmail.com> wrote: > Hi all > > I trying create an event in calendar I use OAuth 2.0 for the autentication > in calendar api i get the token OAuth but when i send the entry calendar the > server response 200 code but i expected an response 201 code CREATE my code > is : > > public void CreatEvent( String Token) { > > String calendarURL = > https://www.google.com/calendar/feeds/default/private/full; > String token=Token; > > HttpURLConnection conn = (HttpURLConnection)(new > URL(calendarURL)).openConnection(); > > //conn.setInstanceFollowRedirects(false); > conn.setDoInput(true); > conn.setDoOutput(true); > //conn.setInstanceFollowRedirects(false); > conn.setFollowRedirects(false); > // Set the properties of the conn: the Http method, the content type > // of the POST request and the authorization header > conn.setRequestMethod("POST"); > conn.setRequestProperty("Content-Type", "application/atom+xml"); > conn.setRequestProperty("Host", "accounts.google.com"); > conn.setRequestProperty("Authorization", "OAuth " + token);// <-- > Token > //conn.setRequestProperty("GData-Version", "2"); > //conn.setRequestProperty("X-If-No-Redirect", "1"); > > > String par ="<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd=' > http://schemas.google.com/g/2005'>" + > "<category scheme='http://schemas.google.com/g/2005#kind' " + > "term='http://schemas.google.com/g/2005#event'></category>" + > "<title type='text'>Tennis with Beth</title>" + > "<content type='text'>Meet for a quick lesson.</content>" + > "<gd:transparency" + > "value='http://schemas.google.com/g/2005#event.opaque'>" + > "</gd:transparency>" + > "<gd:eventStatus" + > "value='http://schemas.google.com/g/2005#event.confirmed'>" + > "</gd:eventStatus>" + > "<gd:where valueString='Rolling Lawn Courts'></gd:where>" + > "<gd:when startTime='2011-07-20T15:00:00.000Z'" + > "endTime='2011-07-20T17:00:00.000Z'></gd:when>" + > "</entry>"; > //conn.connect(); > DataOutputStream wr = new DataOutputStream(conn.getOutputStream()); > wr.writeBytes(par); > wr.flush(); > String msg = conn.getResponseMessage(); > int resp = conn.getResponseCode(); <----Here i get the code 200 but i > expected an code 201 . The event is not created > //InputStream isE = conn.getErrorStream(); > //String Html = inputStrimtoString(isE); > InputStream is = conn.getInputStream(); > String html2 = inputStrimtoString(is); * * > * > * > * > * > *tks for help * > > -- > 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 > google-calendar-help-dataapi@googlegroups.com > To unsubscribe from this group, send email to > google-calendar-help-dataapi+unsubscr...@googlegroups.com > For more options, visit this group at > http://code.google.com/apis/calendar/community/forum.html > -- Alain Vongsouvanh -- 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 google-calendar-help-dataapi@googlegroups.com To unsubscribe from this group, send email to google-calendar-help-dataapi+unsubscr...@googlegroups.com For more options, visit this group at http://code.google.com/apis/calendar/community/forum.html