0
votes

I'm new to service fabric and I need please small help... I have front-end stateless .NET CORE 2.0 service. This web service will communicate with multiples stateless .NET CORE 2.0 APIs. - (I would like to have for each functionality separated API service...)* In each sample code is communication only with stateless service (not .NET CORE 2.0)... I have in API service code in controller, but I don't any exactly, how can I call this code from front-end web service. How to implement circuit breaker in this scenario. etc. Can someone help?

1
Do you want to call web-api from a stateless service?Vivek Sharma
Yes, I have stateless Web service and i need call Stateless Api (Both . NET CORE 2.0)Miroslav Siska

1 Answers

1
votes

If you want to call REST API(or WEB-API) from .net core , you can do something like this:

var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
    new MediaTypeWithQualityHeaderValue("application/json"));

var stringTask = client.GetStringAsync("http://localhost:9098/api/User");

var msg = await stringTask;
Console.Write(msg);

Source: https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/console-webapiclient