Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

HTTP_Request2 Issues with APIs


#1

I am trying to replace curl calls for php bindings with HTTP_Request2, but getting below issue with simple get method

Code Example :

$request = new HTTP_Request2(‘https://XXXXX.testrail.io/index.php?/api/v2/get_case/1’, HTTP_Request2::METHOD_GET);

$request->setHeader([
‘Expect’ => ‘’,
‘Content-Type’ => ‘application/json’,
‘Authorization’ => ‘Basic USER:PASSWORD’,
]);

$res = $request->send();

Response Error :

body:protected] => {“error”:“Content-Type header missing (use Content-Type: application/json)”}