Hello All, I have been trying to use VB.NET to add events to my calendar. I have run into a problem when sending the event info. I keep getting a "400 Bad Request" error. I was hoping someone here could be of some help. I'll leave out the portion of the code that gets the Auth token because that works.
............... strURL = "http://www.google.com/calendar/feeds/default/private/full" strFormData ="<entry xmlns='http://www.w3.org/2005/Atom'" & vbCrLf & _ "xmlns:gd='http://schemas.google.com/g/2005'>" & vbCrLf & _ "<category scheme='http://schemas.google.com/g/2005#kind'" & vbCrLf & _ "term='http://schemas.google.com/g/2005#event'></category>" & vbCrLf & _ "<title type='text'>Do Stuff</title>" & vbCrLf & _ "<content type='text'>There's lots of stuff to do.</content>" & vbCrLf & _ "<author>" & vbCrLf & _ "<name>Steve</name>" & vbCrLf & _ "<email>[EMAIL PROTECTED]</email>" & vbCrLf & _ "</author>" & vbCrLf & _ "<gd:transparency" & vbCrLf & _ "value='http://schemas.google.com/g/2005#event.opaque'>" & vbCrLf & _ "</gd:transparency>" & vbCrLf & _ "<gd:eventStatus" & vbCrLf & _ "value='http://schemas.google.com/g/2005#event.confirmed'>" & vbCrLf & _ "</gd:eventStatus>" & vbCrLf & _ "<gd:where valueString='Anywhere'></gd:where>" & vbCrLf & _ "<gd:when startTime='2006-11-28T15:00:00.000Z'" & vbCrLf & _ "endTime='2006-11-28T17:00:00.000Z'></gd:when>" & vbCrLf & _ "</entry>" Dim request As HttpWebRequest Dim response As HttpWebResponse = Nothing Dim reader As StreamReader Dim byteData() As Byte Dim postStream As Stream = Nothing 'Create the web request request = DirectCast(WebRequest.Create(strURL), HttpWebRequest) 'Set type to POST request.Method = "POST" request.ContentType = "application/x-www-form-urlencoded" request.Headers.Add("Authorization: GoogleLogin auth=" & AuthCode) 'Create a byte array of the data we want to send byteData = UTF8Encoding.UTF8.GetBytes(strFormData) 'Set the content length in the request headers request.ContentLength = byteData.Length 'Write data Try postStream = request.GetRequestStream() postStream.Write(byteData, 0, byteData.Length) Finally If Not postStream Is Nothing Then postStream.Close() End Try Try 'Get response response = DirectCast(request.GetResponse(), HttpWebResponse) 'Get the response stream into a reader reader = New StreamReader(response.GetResponseStream()) txtTextBox.AppendText(reader.ReadToEnd()) Finally If Not response Is Nothing Then response.Close() End Try .......... I receive the error during the second Try branch. I am wondering if the problem lies with the posting of bytes instead of plain text. However I haven't had any luck learning how to post plain text with VB.NET. There is great documentation on how to do this with VB6 at http://www.thepoorhouse.org.uk/using_google_calendar_api_via_visual_basic_6 but VB.NET is entirely different as I have found out the hard way. I even tried using their example program and found out it doesn't work. It too gets a "400 Bad Request". Any help would be greatly appreciated. Thanks. Sincerely GiantsFanMan11 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
