I
iiFranz
Guest
I want to manually set the headers.
// variable cookie = 587D863E6BBA6EFA11881BDAC19D9E6F; Path=/mobile; HttpOnly
// My headers:
//Headers = {Set-Cookie: JSESSIONID=155F342A59F5AABA19EA77161731EBF9; Path=/mobile; HttpOnly,
//JSESSIONID=587D863E6BBA6EFA11881BDAC19D9E6F; Path=/mobile; HttpOnly
// Transfer-Encoding: chunked
// Date: Mon, 06 Jan 2020 19:53:39 GMT
// }
public async Task<ObservableCollection<Car>> GetCar()
{
var client = new HttpClient();
var uri = new Uri(string.Format(server+"/mobile/listcar.htm", string.Empty));
string jsonData = @"";
var contentPOST = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = new HttpResponseMessage();
response.Headers.Add("Set-Cookie", cookie); // Add headers
response = client.PostAsync(uri, contentPOST).Result; // My headers changed
var res = await response.Content.ReadAsStringAsync();
var items = JsonConvert.DeserializeObject<ObservableCollection<Car>>(res);
return items; // Empty list
}
Continue reading...
// variable cookie = 587D863E6BBA6EFA11881BDAC19D9E6F; Path=/mobile; HttpOnly
// My headers:
//Headers = {Set-Cookie: JSESSIONID=155F342A59F5AABA19EA77161731EBF9; Path=/mobile; HttpOnly,
//JSESSIONID=587D863E6BBA6EFA11881BDAC19D9E6F; Path=/mobile; HttpOnly
// Transfer-Encoding: chunked
// Date: Mon, 06 Jan 2020 19:53:39 GMT
// }
public async Task<ObservableCollection<Car>> GetCar()
{
var client = new HttpClient();
var uri = new Uri(string.Format(server+"/mobile/listcar.htm", string.Empty));
string jsonData = @"";
var contentPOST = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = new HttpResponseMessage();
response.Headers.Add("Set-Cookie", cookie); // Add headers
response = client.PostAsync(uri, contentPOST).Result; // My headers changed
var res = await response.Content.ReadAsStringAsync();
var items = JsonConvert.DeserializeObject<ObservableCollection<Car>>(res);
return items; // Empty list
}
Continue reading...