Postman Http Post Request - How to send one string in body

Viewed 1524

I'm trying to pass a string inside the Body of HttpPost Request with Postman, but debugging in visual studio, the post request of my WebApi don't receive the value and so the string is setted to null. I won't pass string in url but in body (it's important). Below the call to my web api post

[HttpPost]
public IActionResult Get(string myString) 
{
    //do something with myString
}

I have already tried to set the value in the URL and it works (http: // myapi / api / foo? MyString = something) But if I try to put it as a parameter of the body (raw -> json or form-data or it is not passed. It doesn't work.

I'm sure I make some mistakes, but I don't know about what

If it's duplicated, i'm sorry, but I have not found anything about it.

Update:
Both of @Sajid's suggestions in comments are correct. If you indicate a single string with [FormBody] in the method signature of the WebApi, or if the string is integrated into a class, the WebApi receives myString value from Postman

0 Answers
Related