Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With "frombody" attribute, parameter of Web Api method recieves null value while testing it with Postman

Given below is my WebApi method, and I want to test it with Postman, but whenever I submit the request, myKey always contains the null value.

[Route("Complete")]
[HttpPost]
[Authorize]
public async Task<IHttpActionResult> Complete([FromBody]string myKey)
{
    // My logic
}

And this how I am submitting the request via Postman. enter image description here

I have found many post suggesting how can we submit the data from Web but not a single one showing same using Postman.

Can you please guide me to get the value of myKey via Postman tool?

like image 750
Jitender Kumar Avatar asked Dec 25 '22 04:12

Jitender Kumar


1 Answers

Pass just the value from the request body. When you add the [FromBody] attribute for a simple type parameter like string, the body will be read as string.

enter image description here

like image 114
hyperbeam22 Avatar answered Dec 28 '22 05:12

hyperbeam22