Disable urlencode in POST request in Guzzle
-
20-12-2019 - |
Question
I am trying to post some data and Guzzle automatically urlencode() all post values. I want to disable it because its acting weird (There is a problem with the Enter character). I searched the documentation and found a reference about this
$query->useUrlEncoding(false);
but its about GET requests.
Also documentation says : "URL encoding can be disabled by passing false, enabled by passing true, set to use RFC 1738 by passing Query::FORM_URLENCODED (internally uses PHP's urlencode function), or set to RFC 3986 by passing Query::RFC_3986 (this is the default and internally uses PHP's rawurlencode function)."
Any idea how to do this?
Solution
For those looking, Guzzle has been completely rewritten & the docs are not yet 100%
The method is now on the Query object, and can be set like:
$request->getQuery()->setEncodingType(false);
OTHER TIPS
Do it like this:
$request->getQuery()->useUrlEncoding(false);
Check out their API Doc for more info http://api.guzzlephp.org/class-Guzzle.Http.QueryString.html