skip to Main Content

How to pass JSON array in body of web api c#

I am trying to capture a JSON array of string from POST Request in web api. [HttpPost] [Route("")] public async Task<IHttpActionResult> CancelItems([FromBody] List<string> items) { //codes } But I am getting null in items. Post Body: { "items":[ "1034908029943809497", "1034908029943809494"…

VIEW QUESTION

Why does Results.Json special-case null (and can I get it to stop doing that)?

Consider the following minimal repro example using the default ASP.NET Core template: var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); // Content-Type application/json, Body: true app.MapGet("/True", () => Results.Json(true)); // Content-Type application/json, Body: "string" app.MapGet("/String", () => Results.Json("string")); // Content-Type…

VIEW QUESTION
Back To Top
Search