Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The GET request in Minimal API is designed to retrieve data from the server, whereas sending a JSON object typically involves posting data to the server. In order to send a JSON object using Minimal API, you need to use the appropriate HTTP verb and specify the correct endpoint URL.

To send data through a POST request, you can use the [HttpPost] attribute in your Minimal API controller and pass in the JSON data as a parameter. For example:

[HttpPost("/endpoint")]
public IActionResult PostData([FromBody] MyModel model)
{
   // Process the received data
   return Ok();
}

Here, the [FromBody] attribute tells Minimal API to deserialize the JSON data into the specified model.

On the client-side, you can use a tool like Postman or fetch() in JavaScript to send the POST request with the JSON object as the body.

If you're still having trouble, it may be helpful to check your network requests to ensure that the POST request is being sent correctly and that the API endpoint is being hit.