Welcome Guest, Not a member yet? Register   Sign In
curlrequest not updating the headers

It seems that the "curlrequest" is not updating the header when I make 2 API calls right after another. One API call to get the token (with 2 header items) then again call the second API with the Token in the header (3 header items).

Second API call keeps failing as the header is not getting updated.

To test this I got the Token from the 1st and Hard corded it to the second and disable the 1st call, then it worked.

$client = \Config\Services::curlrequest();

$body = '{"username":"[email protected]","password" : "'.$keys->pw.'"}';

/// 1st call
$result = $client->setBody($body)->post($keys->url.'/v1/login/', [
'headers' => [
'Content-Type' => 'application/json',
'x-api-key' => $keys->key
$info = json_decode($result->getBody());

///2nd call

$result2 = $client->get($keys->url.'/v1/members/data/'.$member_id, [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'JWT '.$info->token,
'x-api-key' => $keys->key
'debug' => true,
'http_errors' => false


Please help!

Messages In This Thread
curlrequest not updating the headers - by chakycool - 06-17-2021, 07:35 AM

Theme © iAndrew 2016 - Forum software by © MyBB