문제

I'm trying to use HTTParty to manage requests to an API. These are the instructions from the documentation:

url: https://www.havelockinvestments.com/r/orderbook

Required Post Variables symbol: "VTX"

Return Data

status: Contains 'ok' or 'error'

message: Contains error message if applicable

bids: Contains Bids array, as price=>amount pairs

asks: Contains Asks array, as price=>amount pairs

This is what I'm putting in my Ruby script:

require 'httparty'

response = HTTParty.post(
  'https://www.havelockinvestments.com/r/orderbook', 
  :query => { :symbol => "VTX" }
)

But I'm getting an error response:

{"status":"error","message":"post:symbol is required"}

What am I doing wrong here when posting the symbol variable?

The original documentation is at: https://www.havelockinvestments.com/apidoc.php

도움이 되었습니까?

해결책

Documentation seems a bit sparse on the HTTParty Github page, but from the examples it looks like you specify the parameters in a hash as a value to the :body key in the options for HTTParty#post

Like so:

response = HTTParty.post('https://www.havelockinvestments.com/r/orderbook', {body: {symbol: "VTX"}})
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top