Unable to add header for post method in dio in Flutter

Dio library key working perfectly fine in my case if we pass small case key value

For example,

Dio dio = new Dio();
dio.options.headers['content-Type'] = 'application/json';
dio.options.headers["authorization"] = "token ${token}";
response = await dio.post(url, data: data);                                                      

make sure you write key in small case, that’s work for me.

Leave a Comment