Thread: ASP.NET/Consuming Web API(s) In ASP.NET Core MVC Application

Consuming Web API(s) In ASP.NET Core MVC Application

At least this is a generic approach how to do it:

Consuming Web API(s) In ASP.NET Core MVC Application





Re: Consuming Web API(s) In ASP.NET Core MVC Application

This is call not from ASP.NET Core, but it gives you more information how this could be done:

Call a Web API From a .NET Client (C#)





Re: Consuming Web API(s) In ASP.NET Core MVC Application

This is a console application and very short example:

Consuming a WebAPI Service With .NET Core 2.0





Re: Consuming Web API(s) In ASP.NET Core MVC Application

To whom who likes learn from videos:

.Net Core - Server Client Web API HTTP





Re: Consuming Web API(s) In ASP.NET Core MVC Application

Post to Web Api from C# code:


var client = new System.Net.Http.HttpClient();

var response =

client.PostAsync(http://localhost:5000/api/test/30/savedataproperty

, new StringContent("{\"Id\":1234}", Encoding.UTF8, "application/json")).Result;






Re: Consuming Web API(s) In ASP.NET Core MVC Application

Build web APIs with ASP.NET Core


Couple tricks for your Web Api controller to accept not valid POSTs:


services.Configure<ApiBehaviorOptions>(options =>
{
    options.SuppressConsumesConstraintForFormFileParameters = true;
    options.SuppressInferBindingSourcesForParameters =
true;
    options.SuppressModelStateInvalidFilter =
true;
});





Re: Consuming Web API(s) In ASP.NET Core MVC Application
How to call PUT method from Web Api using HttpClient?