I am trying to call one api. When I call it from one controller it works fine but when I try to call it from another controller it does not work properly.
Getting message
array (
'requestError' =>
array (
'serviceException' =>
array (
'messageId' => 'UNAUTHORIZED',
'text' => 'Invalid login details',
),
),
)
It was interesting reason. Actually the controller from where it was not working proper was also sending one curl request. So while it send the curl request it set the options and header in the curl. So when I was calling in other controller it was performing properly.
Solutions
I have tried the 3rd solution. So before calling curl I call two functions
$this->curl->setHeaders([]);
$this->curl->setOptions([]);
I hope it will help and save your time:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.