Home > Enterprise >  Send header in get request using Laravel Http Client
Send header in get request using Laravel Http Client

Time:02-18

I want to send Header using Http Client in get() method, let me share my code with you.

Http::get('https://subscriptions.zoho.com/api/v1/plans')->withHeader(['Authorization', $zohoToken]);

I want to pass these headers but don't know how to pass headers in http::get() request

$header = array(
         'Authorization: Zoho-oauthtoken ' . $accessToken,
         'Content-Type: application/json' );

CodePudding user response:

Use here withHeaders method

Http::withHeaders([
     'Authorization' =>  'Zoho-oauthtoken ' . $accessToken,
     'Content-Type' => 'application/json' 
])->get('https://subscriptions.zoho.com/api/v1/plans');
  • Related