Post XML to Google Calendar API
Posted: Sun Mar 01, 2009 1:16 am
Hi,
I am experimenting withe Google Calendar API and am struggling with how to post the following XML:
I am authenticating correctly to Google but every time I try to post I get an error of Bad Request.
Here is my script:
Any and all help would be greatly appreciated.
Thanks,
Gary
I am experimenting withe Google Calendar API and am struggling with how to post the following XML:
Code: Select all
<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='2006-04-17T15:00:00.000Z'
endTime='2006-04-17T17:00:00.000Z'></gd:when>
</entry>
Here is my script:
Code: Select all
on mouseUp
libUrlSetSSLVerification false
set the sslcertificates to "/usr/share/curl/curl-ca-bundle.crt"
put "myLogin@gmail.com" into theEmail
put "myPassword" into thePassword
set the httpheaders to ""
put "https://www.google.com/accounts/ClientLogin" into theURL
put libUrlFormData("accountType", "HOSTED_OR_GOOGLE", \
"Email", theEmail, \
"Passwd", thePassword, \
"service", "cl", \
"source", "gwt-lagb-1") into theData
post theData to theURL
put it into field "output"
--read the AUTH string
set the itemdelimiter to "="
put the last item of field "Output" into AUTH
put "http://www.google.com/calendar/feeds/default/private/full" into curlURL
put "Content-type: application/atom+xml" &LF &"Authorization: GoogleLogin auth=" &AUTH into field "HEADER"
set the httpheaders to field "HEADER"
get field "myevent"
put it into theData
post theData to curlURL
put it into field "output"
--Google sends a SSID cookie that has to be included if the first attempt fails
if field "Output" contains "Moved Temporarily" then
put offset("gsessionid=",field "Output") into fcharSSID
put offset(">here<",field "Output")- 2 into lcharSSID
put char (fcharSSID) to (lcharSSID) of field "Output" into SSID
get field "myevent"
put it into theData
put curlURL & "?" & SSID into curlURL2
post theData to curlURL2
put it into field "Output"
end if
end mouseUp
Thanks,
Gary