Christopher
Christopher

Reputation: 3469

Post request with GuzzleHttp

I'm trying to make a post request like this example:

$response = $guzzle->post('http://www.website.com/abc.asp?2014:62/9/931/99999', [
                 'body' => [ 'f' => 'json' ]
            ]);

But when i run that code i get an 505 error because the url was literally encoded after ?.

Upvotes: 2

Views: 442

Answers (1)

ffsantos92
ffsantos92

Reputation: 366

You should disable query string encoding. Try this example:

$request = $guzzle->createRequest(
                  'POST', 
                  'http://www.website.com/abc.asp?2014:62/9/931/99999', [
                     'body' => [ 'f' => 'json' ]
               ]);

$request->getQuery()->setEncodingType(false); // magic line :-)

$response = $guzzle->send($request);

Upvotes: 1

Related Questions