If I send “requestJsonContent” as is (without making it
“percent-encoded”)
to the remote service endpoint expecting “urlencoded”, then the service
request succeeds. However, if I do make “requestContent” to be
“percent-encoded” by calling “CGI.escape()”, then the service request
fails.
Curious, with the declaration of “request[“Content-Type”] =
“application/x-www-form-urlencoded””, is this making “request.body” to
be “percent-encoded”, and that is why I do not need to assign a
“percent-encoded” value?
I think there’s some confusion here. The data you’re sending looks like
JSON to me, which in this case is one format you could use to transmit
two
key-value pairs. Percent encoding is an alternative format.
I’d expect the percent-encoded equivalent to look like:
username=third_party_int%40bluefish.com&password=redfish
Whatever you used to construct that json string should be replaced with
some CGI.escape()-using algorithm.
*unless the server is actually expecting to receive a single entity
(which
is a json string) – in which case to be x-www-form-urlencoded you
should
prefix the value (the json string) with a form field name, e.g.
“myjsonstring=” + CGI.escape(requestContent)
Cheers,
Matty
Sent from my android
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.