Posting JSON with http_request

Hello,

It looks like posting JSON with http_request broke in Chef 11.8. (See:
https://tickets.opscode.com/browse/CHEF-4877) Does anyone know of a
workaround?

Thanks,

-Nathan

On Friday, March 14, 2014 at 7:25 AM, Nathan Mische wrote:

Hello,

It looks like posting JSON with http_request broke in Chef 11.8. (See: https://tickets.opscode.com/browse/CHEF-4877) Does anyone know of a workaround?

Thanks,

-Nathan
Convert the body to a JSON string with {“thing” => “value”}.to_json, and add the correct content-type header.

--
Daniel DeLeo

Thanks Daniel. Converting the documentation sample to the following works:

http_request "posting data" do
action :post
url "http://example.com/check_in"
message ({:some => "data"}.to_json)
headers({"AUTHORIZATION" => "Basic
#{Base64.encode64("username:password")}","Content-Type" =>
"application/data"})
end

Do you know, has the behavior of http_request changed and the documentation
(http_request Resource) not been
updated? Or is this a regression?

Thanks Again,

-Nathan

On Wed, Mar 19, 2014 at 11:44 AM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, March 14, 2014 at 7:25 AM, Nathan Mische wrote:

Hello,

It looks like posting JSON with http_request broke in Chef 11.8. (See:
https://tickets.opscode.com/browse/CHEF-4877) Does anyone know of a
workaround?

Thanks,

-Nathan
Convert the body to a JSON string with {"thing" => "value"}.to_json, and
add the correct content-type header.

--
Daniel DeLeo