Questions tagged [minimal-apis]

Minimal APIs were introduced in ASP.NET Core 6 and are architected to create HTTP APIs with minimal dependencies. They are ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.

Minimal APIs were introduced in ASP.NET Core 6 and are architected to create HTTP APIs with minimal dependencies. They are ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.

Answers for many question can be found in the documentation.

236 questions
1
vote
1 answer

How to provide OpenAPI 'tag' group descriptions for a .NET Core 7 minimal API?

I've grouped my API endpoints into two tag/groups: "MCP Provider" and "Nexgen Provider". How can I apply a description to the tags themselves?
Terry
  • 2,148
  • 2
  • 32
  • 53
1
vote
0 answers

What proper technique for MAUI to use API for Login

I have a Blazor Server web application that uses Identity(DbContext, ApplicationUser) to login and register users. I am creating a .Net Core 7.0 Web API to handle the login and database interactions for a MAUI Blazor hybrid mobile app that will use…
1
vote
0 answers

When I host 2 apps (Web API and Blazor server) on Windows Server 2019, the API localhost port refuses to connect to SQL Server database on IIS

When I publish both projects to a local Windows IIS, they both run smoothly, but when I publish to Windows Server 2019, I get an error No connection could be made because the target machine actively refused it.(localhost: 7112) Please help me -…
Letuka
  • 11
  • 2
1
vote
1 answer

Post request to Minimal API service with JSON body

I've got a minimal API service with a MapPost: app.MapPost("/sendmessage", (RabbitMessage rm) => server.SendMessage(rm.exchange, rm.routingkey, rm.message)); app.Run(); record RabbitMessage(string exchange, string routingkey, string message); It…
Serve Laurijssen
  • 9,266
  • 5
  • 45
  • 98
1
vote
2 answers

c# how to pass stored procedure parameter into api dynamically

I'm creating web api using .net core7 minimal api. I create a function to call stored procedure which get from table in database. I'm facing a problem to pass the sp parameter into the function. Example of…
1
vote
1 answer

Is it possible to use app.UseWhen() to only have endpoints with specific conditions?

I have this code: app.UseWhen(context => context.User.Identity?.IsAuthenticated ?? false, applicationBuilder => { app .MapGet("/User", (HttpContext context) => Json(context.User.Identity, new JsonSerializerOptions() { …
Wim ten Brink
  • 25,901
  • 20
  • 83
  • 149
1
vote
1 answer

How to configure json Name Case policy while using MinimalApi

I'm trying to get result from my minimal API who configured in endpoints of my MVC web application my Get action configured like this : endpoints.MapGet( "HO-CFDZU4/api/Currency/Get", …
Igor Markiv
  • 147
  • 12
1
vote
1 answer

System.NullReferenceException when unit testing

I am new to unit testing, I am working on a minimal API project. and I am testing an endpoint with xunit, moq endpoint class - ParticipantsGetAll.cs public class ParticipantsGetAll : IEndpoint { const string…
hanushi
  • 1,169
  • 2
  • 12
  • 27
1
vote
2 answers

Using IResult as return value for "classic" api instead of Minimal API

I have multiple services that return IResult and don´t want to use minimal API structure, but I want to use the same return type IResult, but when I use that in the controller it always returns Ok: Minimal API example that returns 400 Bad…
Moddaman
  • 2,538
  • 3
  • 23
  • 41
1
vote
1 answer

How to access to appsettings from service class in .net core 7 application using minimal api?

I'm working on a .net core 7 application. I have to implement a minimal api using a service class. In this service class, i've to access to appsettings. In the program.cs file, i have the following lines : var builder =…
1
vote
1 answer

Minimal API: Dependency injection error - Unable to resolve service for type

I could not find answer that would resolve my issue. I'm getting 2 exceptions in my minimal API: 1: System.AggregateException Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType:…
1
vote
1 answer

Consuming IAsyncEnumerable via HttpClient (HttpCompletionOption.ResponseHeadersRead) to Blazor WASM not cancelling

I would like to consume an IAsyncEnumerable via a HttpClient from a Blazor-Page. The stream of the results works properly but in case of cancelling the request, the Task does not end on the server side. Server-Side Code (Sample Code->results in an…
1
vote
3 answers

How to read POST parameters in Minimal API, in C# posted by desktop app, .NET 6.0?

I am trying to build a small desktop app (.NET 6.0) that gets data from .NET 6.0 minimal API server. The API server code is: //app.MapPost("/show/", async Task (string myName) => app.MapPost("/show/", async Task (HttpRequest request)…
Srikanth S
  • 1,717
  • 5
  • 16
  • 21
1
vote
1 answer

postAsync returns status as 200, ok but response.content is empty while data is returned in postman

I am using .net 6.0 minimal api with the below simple code in c# app.MapGet("/", () => { return $"{{\"error\":\"0\", \"message\":\"\", \"rows\":\"0\", \"data\":\"It is working !\"}}"; }); My client side code in c# is as below using…
Srikanth S
  • 1,717
  • 5
  • 16
  • 21
1
vote
0 answers

How to make a FromHeader parameter optional in minimal API

I have a minimal API working in C#6, but want to make one of the FromHeader parameters optional. This is the current code: public static void MapGetInstallationByIngressEndpoint(this WebApplication app) => app.MapPost(Url, async ( …
Bjoern
  • 433
  • 3
  • 16