Hi Bala thanks for replying.
I've been trying to follow the same steps but without success. I managed to obtain the authentication code but after that, in order to do the POSTing, must I set up a new connection to http://www.google.com/calendar/feeds/default/private/full ? I have set the content-type to 'application/atom+xml' already. here's a snippet of my code: ~~~~~~~~~~~~~~~~~~~~ // setting up a connection to the login URL. URL url = new URL("https://www.google.com/accounts/ClientLogin"); URLConnection conn = url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); BufferedReader rd = null; String line; // Login and obtain authentication code (successful) String data = "POST /accounts/ClientLogin HTTP/1.0 "; data += "Content-type: application/x-www-form-urlencoded "; data += "accountType=GOOGLE&[EMAIL PROTECTED]&Passwd=ifast123&service=cl&Source=test- test-1"; OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); // some code here to extract the 'auth' // Here I set up a new conenction to the feed address. url = new URL("http://www.google.com/calendar/feeds/default/private/ full"); conn = url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); // Formatting the 'data' to send over // this is the part that I'm not sure of. // auth contains my authentication code. data = "POST http://www.google.com/calendar/feeds/default/private/full "; data += "Authorization: GoogleLogin auth=" + auth + " "; data += " Content-Type: application/atom+xml "; data += " <entry xmlns='http://...> (copied and pasted from the google example)</entry>"; // sending over the HTTP request wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); wr.close(); // print response from request rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); while ((line = rd.readLine()) != null) { out.println(line); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I'll end up with these 2 errors: 1. java.io.FileNotFoundException 2. '400: Bad Request' for url: 'http://www.google.com/calendar/feeds/ default/private/full' Any idea what went wrong? Many thanks and regards, -yijie- On Jun 5, 3:56 pm, Bala <[EMAIL PROTECTED]> wrote: > Hi Yi Jie, > > As long I understand, if you are trying to create a event then you should > keep your content type as "application/atom+xml" for the post request for > creating event. > > If still that doesn't works: > You need to do the following things, to create a entry on a user's account. > 1. Login to the user's account. > 2. After the successful login you will get the auth token from the reponse. > 3. create the request set the auth token it headers to authenticate the > request > (http://code.google.com/apis/calendar/developers_guide_protocol.html#a... > ) > 4. Specify the body for the request. > here is how you can do > it.http://code.google.com/apis/calendar/developers_guide_protocol.html#c... > > Hope this will help. > > Thanks, > Bala > > On 6/5/07, Yi Jie <[EMAIL PROTECTED]> wrote: > > > > > > > > > Hi there, > > > How do I construct a proper HTTP request to create a new calendar > > entry through the XML feed? I'm trying to do it in Java. The Java > > Client Library can't work for me due to some version problems on my > > server. > > > I keep meeting the HTTP/1.0 400 Bad Request error, > > followed by: Content-Type application/x-www-form-urlencoded is not > > valid. > > > How do I specify the correct header and all? > > > Sorry I'm new to these but can't seem to find any solution anywhere. > > Would appreciate any help. thanks.. > > > -yijie- > > -- > Thanks and Regards, > Balaram Barange- 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 -~----------~----~----~----~------~----~------~--~---
