Hello Ryan,

Thanks for the input, I'm following the guide just as it says, but I'm
still getting the 401 unauthorized error when I try to insert my xml. I
think the error lies in how I'm sending the xml but I'm not sure what's
going on.
First I'm sending the initial request to google like this


Response.Redirect("https://www.google.com/accounts/AuthSubRequest?next=http://localhost:4192/Website/testpost.aspx&scope=http://www.google.com/calendar/feeds/default/private/full&session=1&secure=0";)


that redirects me back to my page where I make another request to
https://www.google.com/accounts/AuthSubSessionToken.
That responds with another token then I proceed to insert my event
using the new token in txtToken.text


 Dim strUrl As String
            Dim strFormData As String

            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 request1 As System.Net.HttpWebRequest = Nothing
            Dim response As System.Net.HttpWebResponse = Nothing
            Dim reader As System.IO.StreamReader
            Dim byteData() As Byte
            Dim postStream As System.IO.Stream = Nothing


            'Create the web request
            request1 =
DirectCast(System.Net.HttpWebRequest.Create(strUrl),
System.Net.HttpWebRequest)

            'Set type to POST
            request1.Method = "Post"
            request1.ContentType = "application/atom+xml"
            request1.Headers.Add("Authorization: AuthSub token=" &
txtToken.text)

            'Create a byte array of the data we want to send
            byteData = UTF8Encoding.UTF8.GetBytes(strFormData)

            'Set the content length in the request headers
            request1.ContentLength = byteData.Length

            'Write data
            Try
                postStream = request1.GetRequestStream()
                postStream.Write(byteData, 0, byteData.Length)
            Finally
                If Not postStream Is Nothing Then postStream.Close()
            End Try

            Try
                'Get response
                response = DirectCast(request1.GetResponse(),
System.Net.HttpWebResponse)

                'Get the response stream into a reader
                reader = New
System.IO.StreamReader(response.GetResponseStream())

                txtResponse.Text += reader.ReadToEnd()
            Finally
                If Not response Is Nothing Then response.Close()
            End Try
        End If


When that last part of code runs I get the 401 unauthorized error.
Perhaps you could help me spot whatever flaw is in the code or post an
example.
I greatly appreciate your input. :)

-Ben


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to