lundi 3 septembre 2018

Error consuming API endpoint using GuzzleHttp

I am using GUzzle to consume an API but for some reasons, I get this error 'http_build_query(): Parameter 1 expected to be Array or Object. Incorrect value given'. I don't know what I might be doing wrong. This is my code:

$data = ["name" => "joe doe"];
$jsData = json_encode($data);

            $headers =  [
                'content-type' => 'application/json',
                'Authorization' => "Bearer {$token}"
            ];
            $call = $this->client->post(env('URL'),
                [
                    "headers" => $headers,
                    'form_params' => $jsData
                ]);

            $response = json_decode($call->getBody()->getContents(), true);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire