4

I have loved using HTTParty in the past, but at the moment I'm coming up against a problem I haven't been able to figure out yet.

The API I'm interacting with is successfully contacted like so:

curl -X PUT -d 'id=1175600;status=0' http://www.lingq.com/api_v2/ru/lingqs/?apikey=[long-key]

All other functions in this API I haven't had trouble working into my gem, but this one is giving me grief, hopefully because I'm just not using the httparty gem correctly. I initially tried this:

class Client
  include HTTParty
  base_uri 'lingq.com/api_v2'

  def method
    self.class.put(path,{:body=>{:id=>1175600,:status=>0},
                         :query=>{:apikey=>@apikey}})
  end
end

No dice, it behaves the same as when I issue a GET request through curl. I also tried using httparty from the command line just to get something working to start with:

httparty -a PUT -d 'id=1175600;status=0' http://www.lingq.com/api_v2/ru/lingqs/?apikey=[long-key]

And I get the "411 Length Required", which is what I get when there's nothing in the :body option. I'm still looking, but if anyone has seen this before and could lend some advice I'd appreciate it.

1 Answers1

1

Or, you could simply get the "curb" gem. I don't know if you would like to switch your HTTP API, but that's a viable alternative, especially if you are already fond of cURL.

http://rubygems.org/gems/curb

Hope I helped.

dimitarvp
  • 2,316
  • 2
  • 20
  • 29