nategood / httpful

A Chainable, REST Friendly, PHP HTTP Client. A sane alternative to cURL.
MIT License
1.74k stars 298 forks source link

Got wrong json response #290

Closed ngekoding closed 3 years ago

ngekoding commented 3 years ago

Hi, I got a problem when trying to post data, the body response incorrect. When I try to use Postman, everything is fine.

Here is my code and the results.

public function adjust_balance($username, $adjustment, $comment = '')
{
    $query_params = ['username' => $username, 'token' => $this->token];
    $body = ['adjustment' => $adjustment, 'comment' => $comment];

    $url = $this->base_url.'adjust-balance?'.http_build_query($query_params);
    $response = Request::post($url)->body($body, Mime::FORM)->send();

    return $response;
}
httpful response

And here the response with Postman.

postman response

Can anyone help?

PHP 5.6 httpful ^0.2.20

Thanks in advance

ngekoding commented 3 years ago

Manually add ->expectsJson() solving the problem.