Ruby: Como envio uma solicitação JSON POST usando o Kerb?
Como posso definir o corpo da solicitação CURB como minha string json? Estou tentando fazer uma solicitação JSON POST usando Kerb.
Meu código:
require 'rubygems'
require 'curb'
require 'json'
myarray = {}
myarray['key'] = 'value'
json_string = myarray.to_json()
c = Curl::Easy.http_post("https://example.com"
# how do I set json_string to be the request body?
) do |curl|
curl.headers['Accept'] = 'application/json'
curl.headers['Content-Type'] = 'application/json'
curl.headers['Api-Version'] = '2.2'
end