Laravel - HTTP Client - Headers

Headers may be added to requests using the withHeaders method. This withHeaders method accepts an array of key / value pairs:

    
    $response = Http::withHeaders([
        'X-First' => 'foo',
        'X-Second' => 'bar'
    ])->post('http://example.com/users', [
        'name' => 'Taylor',
    ]);
	

You may use the accept method to specify the content type that your application is expecting in response to your request:

    
    $response = Http::accept('application/json')->get('http://example.com/users');
	

For convenience, you may use the acceptJson method to quickly specify that your application expects the application/json content type in response to your request:

    
    $response = Http::acceptJson()->get('http://example.com/users');