Postman is one of the best tools I have used to call, test and debug my API(s). This morning when I was going through something, I found two brilliant features in postman I wasn't aware of. Postman can generate some request calling code for you and can generate documentation as well. For those who aren't aware, Yes that's true!
I have created a sample API in C#, which looks like this:
// POST api/values
[HttpPost]
public ActionResult<string> Post([FromBody] string value)
{
return ""+value+" is posted";
}
Now to call this API in Postman, it will look something like this:
Now, to generate some code on to call this request, there is a Code button on the top right. Click on it to see the options where you can see a no of languages to generate the code. It looks something like this:
When you click on this code button, a pop-up menu like this will appear:
Now, you can see there is a code snippet and a drop down from where you can select a no of options, as to for which you want to generate the code. The options available are:
Now, click on any of the options, where you will see the code. Copy the code and paste it in your IDE and run!
It would look something like this:
It's done! As simple as that.
Top comments (1)
How can I generate code for an entire collection at once?