Can't send varaible in headers

I’m trying to send a token and company name variables but it always send blank, any idea?

 var response = await http.get(URL, 
    headers: {
          "Accept": "application/json",
          "authorization": 'Bearer ' + token,
          "company_name": company_name
        });

I also try like this

 var response = await http.get(URL, 
    headers: {
          "Accept": "application/json",
          "authorization": 'Bearer $token' ,
          "company_name": "$company_name"
        });

What i mean is than it dosn’t send does variables i check and the variables do have the value so i don’t know what to do. im using “import ‘package:http/http.dart’ as http;”.

I did check my back end and is all ok.

Ideally your second approach should work.

But give the following a try -

Map<String, String> headers = Map();

headers = {
          "Accept": "application/json",
          "authorization": 'Bearer' + token ,
          "company_name": company_name
        }

var response = await http.get(URL, headers: headers)

Let us know here if it works!

1 Like