Closed zacker330 closed 9 years ago
@zacker330 check out the "Custom Entity Body" example on http://unirest.io/ruby.html
@corprew cool. I missing the document. thanks.
Somehow I am unable to do a post with JSON, this is what I did:
response = Unirest.post(
URL,
headers: { "Accept" => "application/json" },
parameters: {keyInJSON: 'valueReceived'}.to_json
)
p response
Am I missing something? The service is throwing error saying missing key, but I am proving everything right. I checked the data with a command line & it works!
I'm also having this problem:
def publish
Unirest.post ENV.fetch('ENDPOINT'),
headers: headers,
parameters: parameters
end
private
def parameters
{
type: @@event_type,
data: @data.deep_transform_keys! { |key| key.to_s.camelize(:lower) }
}.to_json
end
def headers
headers = {
'Accept' => 'application/json',
'Content-Type' => 'application/json' # tried with and without this
}
headers['Authorization'] = bearer_token if @user_id.present?
headers
end
My service is not supporting parameters, just recieve json entity. So I wanna to post json entity to server, how can I do that?
thanks.