'Send header in get request using Laravel Http Client

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


Solution 1:[1]

Use here withHeaders method

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

Solution 2:[2]

You can use Http::withToken()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jignesh Joisar
Solution 2 Hills Victor