Skip to content

Instantly share code, notes, and snippets.

@gregorym
Created July 18, 2011 18:47
Show Gist options
  • Save gregorym/1090307 to your computer and use it in GitHub Desktop.
Save gregorym/1090307 to your computer and use it in GitHub Desktop.
Basecamp Api not working
Basecamp::Message.prefix = "/projects/:project_id/"
# Basecamp::Base.establish_connection!( my info the connecy)
m = Basecamp::Message.new(:project_id => 7584268)
m.title = "greg"
m.body = "plop"
m.author_id = 7714821
m.private = false
m.notify = ["7714823"]
print m.encode
m.save
<?xml version="1.0" encoding="UTF-8"?>
<post>
<notify type="array">
<notify>7714823</notify>
</notify>
<body>plop</body>
<title>greg</title>
<private type="boolean">false</private>
<author-id type="integer">7714821</author-id>
</post>
<notify type="integer">7714823</notify>
ActiveResource::ServerError: Failed. Response code = 500. Response message = Internal Server Error.
module Basecamp
class Message < Base
self.element_name = "post"
def encode(options={})
if known_attributes.include?('notify')
encoded = send("to_#{self.class.format.extension}", options)
notifies = notify.inject("") { |acc, n| acc += %(<notify>#{n}</notify>\n) }
"<request>" + encoded + notifies + "</request>"
else
super
end
end
end
end
Basecamp::Message.prefix = "/projects/:project_id/"
# Basecamp::Base.establish_connection!( my info the connecy)
m = Basecamp::Message.new(:project_id => 7584268)
m.title = "greg"
m.body = "plop"
m.author_id = 7714821
m.private = false
#m.notify = ["7714823"]
print m.encode
m.save
<?xml version="1.0" encoding="UTF-8"?>
<post>
<notify type="array">
<notify>7714823</notify>
</notify>
<body>plop</body>
<title>greg</title>
<private type="boolean">false</private>
<author-id type="integer">7714821</author-id>
</post>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment