http
http copied to clipboard
Cookie inside Request Header
I need to get data from one of my backend services and this request uses session cookie in header. I have the session cookie but when i am sending it to server it is not working the code is throwing exception. I might be wrong passing the cookie to request header Any help would be appreciated . Thanks in advance. I am sharing my code below
/////////**This is my url//////////
Url --->> http://95.217.5.45:8081/api/home
setState(() { _isLoading = true; });
String apiUrl = ApiService.HOMEPAGE;
var response =
await http.get(Uri.parse(apiUrl), headers: {"cookie": token});
//////////////**************This is the error i am getting below *****************/////////////////

//////////////**************This is the Postman Screenshot *****************/////////////////
It is working fine with postman

I have the same problem. Can't make request with cookie.
This is how it's done in curl:
curl -sS -I "url" -H "Cookie: sjv=123"
This is how it's done in python
import requests
response = requests.head('url', cookies={'sjv': '123'})
Dart http not working:
import 'package:http/http.dart' as http;
void main() async {
var res = await http.head('url', headers: {'Cookie': 'sjv=123'});
print(res.body);
}