Hi @osyris ,
To send a request with single parameter, you could try to use the following method:
1. Send parameter via query string.
Append the parameter at the end of the request url, code as below:
//send parameter via query string
var name = "Tom";
var res = axios.post("https://localhost:44310/api/ToDo/CreateCategory?name=" + name);
Api Controller:
[Route("api/[controller]")]
[ApiController]
public class TodoController : ControllerBase
{
[HttpPost("CreateCategory")]
public async Task<IActionResult> CreateCategory(string name)
{
return Ok("Success");
}
The result as below:
2. Send parameter via Form
Code like this:
const resp = axios.post('https://localhost:44310/api/ToDo/CreateCategory', 'name=world');
Api Controller:
[Route("api/[controller]")]
[ApiController]
public class TodoController : ControllerBase
{
[HttpPost("CreateCategory")]
public async Task<IActionResult> CreateCategory([FromForm]string name)
{
return Ok("Success");
}
The result like this:
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion