# EOF Behaviour

**URL:** <https://www.ruby-forum.com/t/eof-behaviour/135829>\
**Category:** Ruby\
**Created:** [April 25, 2008, 1:01pm UTC](https://www.ruby-forum.com/t/eof-behaviour/135829 "2008-04-25T13:01:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanderkerkoff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7feea3/32.png) [@vanderkerkoff](https://www.ruby-forum.com/u/vanderkerkoff)\
**Post date:** [April 25, 2008, 1:01pm UTC](https://www.ruby-forum.com/t/eof-behaviour/135829/1 "2008-04-25T13:01:37Z")

</div>

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](http://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”  
[http://code.google.com/apis/calendar/developers\_guide\_protocol.html#CreatingSingle](http://code.google.com/apis/calendar/developers_guide_protocol.html#CreatingSingle)

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.
