Search code examples
phphttpguzzleguzzle6

Send Body as raw using Guzzle


I am trying to use Guzzle to send POST request to my web service. this service accepts body as raw. It works fine when I use postman but I doesn't using Guzzle. when using Guzzle, I get only the webservice description as I put the web service URL in the browser. here is my code:

    $body = "CA::Read:PackageItems  (CustomerId='xxxxxx',AllPackages=TRUE);";
    $headers = [
        ....
        ....

    ]; 
$client = new Client();
$response = $client->request('POST', 'http://172.19.34.67:9882/TisService',$headers,$body);
echo $body = $response->getBody();

seems headers or body doesn't pass through.


Solution

  • Try like this

    $response = $client->request('POST', 'http://172.19.34.67:9882/TisService',['headers' => $headers, 'body' => $body]);