8 messages in com.googlegroups.google-calendar-help-dataapiRe: Post new entry using HTTP request...
FromSent OnAttachments
John Doe04 Jun 2007 02:55 
Bala05 Jun 2007 07:24 
Lane LiaBraaten (Google)05 Jun 2007 10:57 
John Doe05 Jun 2007 20:42 
John Doe05 Jun 2007 20:44 
Lane LiaBraaten (Google)05 Jun 2007 21:29 
John Doe05 Jun 2007 23:41 
John Doe The Intern06 Jun 2007 02:56 
Subject:Re: Post new entry using HTTP request - in Java
From:Bala (bala@gmail.com)
Date:06/05/2007 07:24:37 AM
List:com.googlegroups.google-calendar-help-dataapi

Hi John,

I think the output stream data part is incorrect, you should write only the post data in the output stream. I don't know how to do it in java. But, there has to be some way of setting the request headers with the connection object.

The post body section, or the output stream should contain only the following:

data = " <entry xmlns='http://www.w3.org/2005/Atom' ... (the sample xml code from the Developer's Guide: Protocol) ... </entry>"

Hope this will help!

On 6/4/07, John Doe <klo@gmail.com> wrote:

Hi there, I need help with this rather fundamental task here but I'm an absolute newbie at communicating using HTTP requests.

I need to add/edit/delete calendar events on my JSP site. I know I shd be using the Java Client Library but for some reason I have to stick to java 1.4.2 (gdata runs on ver 1.5 though) on my server so I need to find some other ways of doing it.

So right now I'm trying to do things using the java URLConnection object.

~~~~~~~~~~~~~~~ String xmlfeed = http://www.google.com/calendar/feeds/em...@gma@(magic cookie)/basic URL url = new URL(xmlfeed); URLConnection conn = url.openConnection(); conn.setDoOutput(true);

BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); while ((line = rd.readLine()) != null) { out.println(line); } rd.close(); ~~~~~~~~~~~~~~~

by doing this, i can retrieve and print out the XML contents of my calendar.

However, I have no idea how to format and send a POST request to my XML feed.

I tried : ~~~~~~~~~~~~~~~~ String data = "POST " + xmlfeed; data += " <entry xmlns='http://www.w3.org/2005/Atom' ... (the sample xml code from the Developer's Guide: Protocol) ... > " OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); ~~~~~~~~~~~~~~~~~

The response that I received was a HTTP/1.0 400 Bad Request .

Can anyone guide me on what I should do to submit a proper request? I've searched through the forums and references, but everybody seems to know how to do it, except for me apparently.

many thanks in advance..