jeudi 17 octobre 2019

Curl POST request using Guzzle 6.3

Currently i am working on laravel 5.2 with guzzle 6.3 with REST API .

A POST request gives me the following error when set to debug to true . I almost tried every answer related to this, but did not work for me.

curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE*

NOTE: At postman and using PHP curl gives me the desired output

My code :

$username = 'XXXXX';
$password = 'XXXXX';
$client = new \GuzzleHttp\Client();
$url = "https://xxxxxxxxxxxxxxxx/xxxxxxx";
$response = $client->post( $url, [
    'auth' => [$username, $password],
    'form_params' => ["consent"=> "X","gstin"=> "xxxxxxxxxx"],
    'headers' => ['Content-type' => 'application/json'],
    'debug' => true
]);

dd($response->getBody());

I also tried with json instead of form_params since i am working with REST API

'json' => ["consent"=> "X","gstin"=> "xxxxxxxxxx"],

Please help.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Bl5Ll3
via IFTTT

Aucun commentaire:

Enregistrer un commentaire