Click here to Skip to main content
15,900,258 members

Comments by Adi_Mag (Top 5 by date)

Adi_Mag 1-Jan-17 13:23pm View    
The service is secured service. To access the get_endpoint. We need to pass the access_token. We can not violate rest principles by making get request as post. Any thoughts on this ?
Adi_Mag 1-Jan-17 13:15pm View    
One more point :
Get Rest Endpoint : http://www.customerservices.com/Customers/{id}?access_token=12345
Is it a right approach?
My earlier approach was to send this access_token in DefaultRequestHeader. But defaultRequsetHeader Causes Issue.
Adi_Mag 1-Jan-17 12:59pm View    
Thanks a lot.
Adi_Mag 1-Jan-17 12:50pm View    
I have used parallel because multiple clients try to access the application. I am mimicking the real time scenario.
Adi_Mag 1-Jan-17 12:44pm View    
My application flow is client===>webapi===>authentication server. We get accesstoken from client request. Then we connect to authentication server for validation. For this validation, we are using httpclient. We need to set the access header of the httpclient with access token. If I use the same instance of HttpClient then the race condition comes up.

Simple POC :

Parallel.For(0, 10,
i =>
{
var guidData = Guid.NewGuid().ToString();
_httpClient.DefaultRequestHeaders.Clear();
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
_httpClient.DefaultRequestHeaders.Add("Guid", guidData);
var response = _httpClient.GetAsync("http://localhost:2967/api/service/GetData").GetAwaiter().GetResul();
var data = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
Console.WriteLine(data);
Console.WriteLine("===============");
});

Error : Getting error, the guid is already added.