質問

I'm trying to send a post to Paypal and they don't want anything to be URI encoded. But HTTParty seems to do this by default and it's breaking things for me. For a simple example, when I try this code:

HTTParty.post("http://google.com/", body: {foo: "http://example.com/bar"})

I see that the post body was actually

foo=http%3A%2F%2Fexample.com%2Fbar

Is it possible to make HTTParty not perform the URI encoding?

役に立ちましたか?

解決

It is possible. Run the class method query_string_normalizer with a proc that doesn't do any URI encoding. This worked for me.

query_string_normalizer proc { |query|
    query.map do |key, value|
        "#{key}=#{value}"
    end.join('&')
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top