I am making the following request using Zend\Http\Request and Zend\Http\Client
//Creating request and client objects
$request = new Request();
$client = new Client();
//Preparing Request Object
$request->setMethod('POST');
$request->setUri('https://my.api.address.com/apiendpointurl1234');
$request->getHeaders()->addHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/json',
'client_secret' => 'asdfasdfasdfasdfasdf',
'client_id' => 'asdfasdfasdfasdfasdf',
'accept' => 'application/json',
'authorization' => 'Basic MTIzNDoxMjM0',
));
$request->getPost()->set(json_encode(array(
'student_id' => '123456',
'short_description' => 'this is short description',
'description' => 'this is detailed description of the question',
)));
//Sending Request
$response = $client->send($request);
var_dump( $response->getBody() );
However the response comes with this error:
"error": "headers: client_id required"
When I poke the API via Postman, it works fine. But when I call it from the PHP application, it turns out that the headers are not being sent correctly, which is giving the above error. Anyone would know why the headers aren't being sent?