Ad

Send Header In Get Request Using Laravel Http Client

- 1 answer

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' );
Ad

Answer

Use here withHeaders method

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