I'm not defining the base_uri but passing the full URL. Below is the updated code.
$keys->url = "https://dommain.com"
$client = single_service('curlrequest');
$result = $client->post($keys->url.'/v2/', [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'JWT '.$access->token,
'x-api-key' => $keys->key
],
'body' => $payload,
'debug' => true
]);
I tried the below method and it worked.
$client->setBody($payload)->post($keys->url.'/v2/',...................
Looks like we can't pass the body payload in the option array.