将 curl api 调用转换为 httparty

Converting curl api call to httparty

我是 Httparty 的新手,我想通过 httparty 进行用户身份验证。 curl 中的命令有效。

curl --data "username=USERNAME&password=PASSWORD&token=132321212" 'https://hekki.isks.com/api/userauth'

我不能完全将其转换为 httparty。到目前为止我有这个。

response = HTTParty.post("https://hekki.isks.com/api/userauth", 
      :username => "hello",
      :password => "no",
      :token => 132321212,
      :headers => { 'Content-Type' => 'application/json' } )

我觉得应该是:

response = HTTParty.post("https://hekki.isks.com/api/userauth",
                         :body=> { 
                                    :username => "hello",
                                    :password => "no",
                                    :token => 132321212 
                                  } )