Seite wählen

Postman – API development and testing made simple

von | Aug 23, 2018 | Development

As a Icinga 2 developer I often use the Icinga 2 REST API to test new features or debug Icinga itself. Of course most people use curl for that kind of task, and so did I.
That resulted in sometimes rewriting the same request a lot over the course of a few weeks. To counter that I just saved my most used requests into my notes which wasn’t that simple to maintain.
A few weeks ago that finally changed as I stumbled across Postman. Postman is a tool for developing, maintaining and testing REST APIs. I’d like to give you a quick rundown of its features, to show you why it has made my development life so much easier.



Requests require, like in most HTTP clients, a method, URL, headers and maybe a body, depending on the method. But in Postman you can also add tests and pre-request scripts written in JavaScript.


Collections and folders:

All your request can be sorted into collections and folders. That allows you to have variables and tests based on your current collection/folder.



In Postman collections and environments can have variables, if needed you can even create global variables. In the first example I used a collection variable called{{icinga-url}} which looks like this https://{{host}}:{{port}}/v1  and itself is based on two environment variables.



The only purpose of environments is to allow you to switch between sets of variables. You might need a URL and some credentials for a Icinga API at localhost and the same variables with different values for a customer setup.


Generate code from requests:

If you wan’t to use a request inside your software, Postman allows you to just export request as code. They provide a few common languages as seen below.


More features:

  • Test requests with JavaScript
  • Monitor APIs
  • Mock APIs
  • Generate API documentation
  • Generate request code from Postman (Curl, Python, C++ and more)
  • Darktheme (Most importent feature obviously)



Over the last few weeks it saved me a lot of time, because I didn’t need to rebuild my requests in curl every time I needed them. And if I’ll ever build an API from scratch, this will help me for sure.

Mehr Beiträge zum Thema Development

Kleine Weihnachtspyramide mit Raspberry Pi

Noch einmal schlafen und dann ist Weihnachten. Passend dazu haben wir von NETWAYS ein kleines Experiment zum selber Nachbauen vorbereitet. Es handelt sich um eine kleine Weihnachtspyramide, die sich mithilfe von Python Code und ein paar Bauteilen ein wenig bewegt und...

Alle Jahre wieder, kommt der Advent of Code

...zumindest seit 2015. Bereits zum achten Mal haben Rätsel- und Programmierfreunde rund um die Welt in der Nacht vom 30. November auf den 1. Dezember dieses Jahr gebannt auf die Veröffentlichung des ersten Rätsels gewartet. Ihr habt davon noch nie gehört und wollt...

Ansible – Testing roles with Molecule

Ansible is a widely used and a powerful open-source configuration and deployment management tool. It can be used for simple repetitive daily tasks or complex application deployments, therefore Ansible is able to cover mostly any situation. If used in complex or...

NETWAYS Support Collector Roadmap

Den Support Collector konnte ich bereits in meinem letzten Blogpost vorstellen. Für alle die den Beitrag verpasst haben, hier kurz umrissen was es ist: Bei dem Tool handelt es sich um einen von uns geschriebenen Datensammler, welche alle möglichen Support relevanten...