Skip to content
Browse files

Check if the body is empty before parsing

When we create an object using the non rest interface, Basecamp sends an empty response body. This is to avoid an exception trying to parse an empty body.
  • Loading branch information...
1 parent cb598e9 commit 43a72a28235706aa3ccc12b037bfb0d73d3bd700 @anibalcucco committed
Showing with 1 addition and 0 deletions.
  1. +1 −0 lib/basecamp/base.rb
View
1 lib/basecamp/base.rb
@@ -28,6 +28,7 @@ def request(path, parameters = {})
response = Basecamp.connection.post(path, StringIO.new(convert_body(parameters)), "Content-Type" => content_type)
if response.code.to_i / 100 == 2
+ return {} if response.body.blank?
result = XmlSimple.xml_in(response.body, 'keeproot' => true, 'contentkey' => '__content__', 'forcecontent' => true)
typecast_value(result)
else

0 comments on commit 43a72a2

Please sign in to comment.
Something went wrong with that request. Please try again.