anibalcucco / basecamp-wrapper

Using the Basecamp API with Ruby
Apache License 2.0
77 stars 29 forks source link

404 Errors when creating messages #16

Closed bunswo closed 12 years ago

bunswo commented 12 years ago

I'm getting 404 errors when trying to create Basecamp messages using the wrapper.

I can create Projects successfully:

p = Basecamp::Project.new() p.name = 'My Test Project' p.save

The project shows up in Basecamp on the web without problem.

And I can grab the new project id:

proj_id = p.id

But when I try to create messages on the project...

m = Basecamp::Message.new(:project_id => proj_id) m.title = 'Message in a bottle' m.body = 'Another lonely day, with no one here but me' m.save

It returns a 404 error after the save method:

ActiveResource::ResourceNotFound: Failed. Response code = 404. Response message = Not Found. from /Users/benunsworth/.rvm/gems/ruby-1.9.3-p0/gems/activeresource-3.2.0/lib/active_resource/connection.rb:136:in `handle_response' ...

Any idea?

Thanks, Ben

anibalcucco commented 12 years ago

Hey,

I pushed a fix, we were overriding the element_name in Resource ignoring the "special" element name setting necessary in Basecamp::Message to use "post" in the API calls instead of "message".

The problem was only in rails >= 3, that method was ignored in rails < 3.

Can you try the fix by adding the gem like this in your project?

gem "basecamp", :git => "git://github.com/anibalcucco/basecamp-wrapper.git", :ref => "7e67411a847c9bf921e3c8fe489110fbc0dfa53e"

If you confirm it's working, i'll bump the gem version.

Thanks, Anibal

bunswo commented 12 years ago

Hi Anibal --

That worked! I added the gem into my gem file and the message posted to the project.

Yes it was Rails 3.2.0

Thanks so much!

Ben

Ben Unsworth Globacore Interactive Technologies

On 2012-01-26, at 7:37 PM, Anibal Cucco wrote:

Hey,

I pushed a fix, we were overriding the element_name in Resource ignoring the "special" element name setting necessary in Basecamp::Message to use "post" in the API calls instead of "message".

The problem was only in rails >= 3, that method was ignored in rails < 3.

Can you try the fix by adding the gem like this in your project?

gem "basecamp", :git => "git://github.com/anibalcucco/basecamp-wrapper.git", :ref => "7e67411a847c9bf921e3c8fe489110fbc0dfa53e"

If you confirm it's working, i'll bump the gem version.

Thanks, Anibal


Reply to this email directly or view it on GitHub: https://github.com/anibalcucco/basecamp-wrapper/issues/16#issuecomment-3679919

anibalcucco commented 12 years ago

Thanks @bunswo. Version bumped to 0.0.9 and published to rubygems.

bunswo commented 12 years ago

Awesome - While I have you here and before I go too deep -- does your wrapper allow for adding multiple people to a message?

Ben Unsworth Globacore Interactive Technologies

On 2012-01-26, at 10:05 PM, Anibal Cucco wrote:

Thanks @bunswo. Version bumped to 0.0.9 and published to rubygems.


Reply to this email directly or view it on GitHub: https://github.com/anibalcucco/basecamp-wrapper/issues/16#issuecomment-3681272

anibalcucco commented 12 years ago

There's currently no way to do that using the REST API because the notify attribute should be outside the post attributes in the request to create the message and i couldn't find a way to make active resource handle that yet:

<request>
  <post>
    <category-id>#{category_id}</category-id>
    <title>#{title}</title>
    <body>#{body}</body>
    <private>1</private> <!-- only for firm employees -->
  </post>
  <notify>#{person_id}</notify>
  <notify>#{person_id}</notify>
...

But you can always use the non REST API for those special cases:

Basecamp.request "/projects/1234/posts", :post => {:title => "Hello", :body => "World"}, :notify => ["person_id_1", "person_id_2"]

Note: I discovered a bug for that type of calls and i pushed a fix. So, if you want to use that, you have to reference this commit on your Gemfile: 43a72a28235706aa3ccc12b037bfb0d73d3bd700

bunswo commented 12 years ago

Great. Thanks Anibal. That's really helpful.

Sent from my iPhone

On 2012-01-27, at 3:14 PM, "Anibal Cucco" reply@reply.github.com wrote:

There's currently no way to do that using the REST API because the notify attribute should be outside the post attributes in the request to create the message and i couldn't find a way to make active resource handle that yet:

<request>
 <post>
   <category-id>#{category_id}</category-id>
   <title>#{title}</title>
   <body>#{body}</body>
   <private>1</private> <!-- only for firm employees -->
 </post>
 <notify>#{person_id}</notify>
 <notify>#{person_id}</notify>
...

But you can always use the non REST API for those special cases:

Basecamp.request "/projects/1234/posts", :post => {:title => "Hello", :body => "World"}, :notify => ["person_id_1", "person_id_2"]

Note: I discovered a bug for that type of calls and i pushed a fix. So, if you want to use that, you have to reference this commit on your Gemfile: 43a72a28235706aa3ccc12b037bfb0d73d3bd700


Reply to this email directly or view it on GitHub: https://github.com/anibalcucco/basecamp-wrapper/issues/16#issuecomment-3693318