EOF Behaviour

Hello everyone

I’m sending an event to google calendar from my ruby code.

I got it all working lovely with ClirntLogin, but you need to get it
working with their AuthSub authentication mechanism for it to be of any
real use.

The problem I’m getting is this.

here’s my post code

http = Net::HTTP.new(‘www.google.com’, 80)
path = “/calendar/feeds/default/private/full”
event = XMLEvent
headers = {‘Authorization’ => “AuthSubtoken=”#{authsub_token}"",
‘Content-Type’ => ‘application/atom+xml’, ‘Charset’ => ‘utf8’}
http.post(path, XMLevent, headers)

Now this all works fine, goes through the redirect nonsense that google
enjoy and posts up to the calendar if I create XMLEvent like this.

XMLEvent = “Long line of the complete XML feed with variables manually
entered described in the link below”

But if I use EOF to create a template of the structure of the xml and
pass the event details into it from a web form, like this, it fails with
a 400, bad request.

def template(event={})
content = <<EOF

<?xml version="1.0"?>

#{event[:title]} #{event[:content]} EOF

The error back from google is this
HTTP/1.1 400 Bad Request…Content-Type: text/plain;
charset=UTF-8…Transfer-Encoding: chunke
d…Date: Fri, 25 Apr 2008 10:45:41 GMT…Expires: Fri, 25 Apr 2008
10:45:41 GMT…Cache-Contro
l: private, max-age=0…Server: GFE/1.3…Connection:
Close…28…Invalid query parameters:&l
t;entry xmlns…

It’s as if the XML has been translated into another language.

Does anyone have any ideas how to resolve this issue?

I’ve been told I need to html encode the body, but I don’t know what the
body is or how to html encode it.

I tries using CGI.escape on the XMLEvent itself after it had been
created with EOF but google laughed it’s merry socks off at what I
passed over on that attempt.

Any help, as always, greatly appreciated.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs