loading...
Cover image for Bye bye Postman ! Let's share your REST API calls in team, easily !
Monisnap

Bye bye Postman ! Let's share your REST API calls in team, easily !

monisnapjonathan profile image Jonathan BROSSARD ・2 min read

As developer, we are using tools to make REST API calls (Postman, Insomnia, PostWoman...), and these tools are very usefull.

The limits

Make calls to test an API is fine, but if you want to edit, version, or simply share it with your team ... it's not very handy.

Indeed, you can use Postman paid plans for instance, but it means that you need to pay, and it means that all your team needs to use Postman, again one more tool...

Do you know REST Client ?

Logo REST Client VS Code Extension

REST Client* is a VS Code extension.

It will let you to send HTTP requests and view responses into VS Code. And only based on a text file, which can easily be versioned among your repository. 🙏

Pros

The main advantage is to be able to version and share your API calls.

If you're working on an internal API, you may want to share how to test a new endpoint with your colleagues.

REST Client is a good easy way to do it !

Another good point is simplicity. All you need to do/have, is ONE file. Also, if you jump between projects and do not remember how works an API/Service on which you did not work since a while, just look at this file !

Cons

You have to use VS Code... but for a lot of known reasons among internets, you are using Emacs, VI, or VS Code 😄

What's next ?

Here is how to begin.

The file

Only create a file with .http extension, for instance doc.http

And then, VS Code will show you the file as :

doc.http preview into VS Code

And by clicking on "Send Request", a new tab with all request response details will be opened.

doc.http response preview into VS Code

Go further

You may also use environment variables to easily switch between you env and avoid any api-key or token manually update in the file, or url update etc...

Here is how to use environment variables, just like that :

Here, I created 4 environments : local, dev, staging, production.

These 4 environments have their own host and token variables, with their specific values.
But they also share a variable, named partnerUniqueToken (don't ask me why ... too many partners don't have several env...).

Hope it helps !

Big up to Julien who discovered this extension !

Discussion

pic
Editor guide
Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Many thanks @ankush981 , indeed, probably one of the best reason : "why open another RAM-hungry app" !

Collapse
psupanova profile image
Peter Edwards

Ram-hungry? Equipment is cheap compared to salaries these days running out of ram should just not happen even with swapfile disabled

Thread Thread
faridos profile image
faridos

Maybe some people play games while building the app and testing lol

Thread Thread
monisnapjonathan profile image
Jonathan BROSSARD Author

It's more like a mind-set, I don't want to have "one more" app launched. We all already have IDE, Chrome, Sequel, Slack, Trello, Terminal ...

Collapse
harlock123 profile image
Lonnie Watson

For Peter Edwards...
Some unfortunate souls are forced to work with underwhelming equipment that benefit from not having yet another tool running. Regardless of capacity... My personal stuff runs circles around the dev env I have to use for work. Everything I can do with something like VS code I do to make that work system at least usable....

Thread Thread
gergelypolonkai profile image
Gergely Polonkai

Even if i’m not forced (i could easily afford expanding my RAM), some simply doesn’t want to. I refuse to buy RAM just to run another RAM-hogging app (most probably a “Desktop App” built on Electron) and will use a less RAM-demanding, actually native program. If there is none, i need to be really interested in the platform to put some money in using it (not the case most of the time).

So please, optimize for RAM. Even with today’s tech like SSD drives and such it worth it.

Collapse
vicoerv profile image
Vico

Yeah, lagging will mess my mood. if it's not 60fps then I'll not code hahaha just kidding 😂

Collapse
char0n profile image
Vladimir Gorej

Thank you for the article and opening this topic. I been using this feature in JetBrains products for some time. It's a great tool for helping you in local development. Also having an ability to create .http files and store them as part of your CVS and share it with your team is a great benefit. There is a great hidden potential in .http files.

But there are some problems concerning cross tooling compatibility and integration. The concept actually has a name: HTTP Request in Editor Specification. This name is shared by both JetBrains and VS code extensions (partially in form of HTTP Request in Editor) respectively. JetBrains went a step further and created a actual RFC specification strictly based on RFC 7230. VS code extension claims to be based on RFC 2616 which has been obsoleted by RFC 7230 some time ago. So you can have possible problems when created files in VS code and running in them in JetBrains. Both extensions claim to support .http/.rest file extension, but IMHO .http file extension should be used exclusively because .rest can be confused with Docutils reStructuredText Document.

There is also an important question of validation and testing. JetBrains extension supports Response Handlers which can intercept the HTTP Responses, validate and assert them. They can be written in ES5 (JavaScript). These Response Handler files can live along with .http files and make sure when somebody is using those file to make HTTP requests he gets expected response. The only problem is that you have to run .http files (with Response Handlers) in JetBrains IDE. So far I haven't found a library that could run the .http files with Response Handlers via CLI. If there was such a library it would allow us to run API tests based on .http files on CI (good idea for opensource project:) and verify .http files against my API. It would also allow running .http files for people not using JetBrains or VS code IDEs.

So I think there is a great potential in this, and the community can fill some gaps that will allow us to utilize HTTP Request in Editor Specification into it's full potential.

Can HTTP Request in Editor Specification replace Postman? I don't think so, at this point in time. But in future, with more tools, integrations and libraries? I'd say: yes, very possibly.

HTTP Request in Editor specification (by Jetbrains): github.com/JetBrains/http-request-...
RFC 7230 - tools.ietf.org/html/rfc7230#sectio...
RFC 2616 - w3.org/Protocols/rfc2616/rfc2616-s...
Implementation of the spec in mainstream languages: github.com/JetBrains/http-request-...
JetBrains HTTP Client documentation: jetbrains.com/help/idea/http-clien...
Rest CLIENT VS extension: marketplace.visualstudio.com/items...
CLI runner for HTTP Request in Editor jetbrains issue: youtrack.jetbrains.com/issue/WI-42002

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Thanks a lot @char0n for this whole comment, terribly interesting !

Collapse
char0n profile image
Vladimir Gorej

As I found out today JetBrains has actual plans to implement a runner for the spec: youtrack.jetbrains.com/issue/WI-42002

Collapse
alejandrorios profile image
Alejandro Rios

Is there a version of this for Jetbrains??

Collapse
monisnapjonathan profile image
Collapse
alejandrorios profile image
Alejandro Rios

😮 I didn't know it, thanks

Thread Thread
monisnapjonathan profile image
Collapse
nick profile image
Nick Rameau

Meh, Postman is still better than this in my humble opinion. They're making you pay for a good reason. I'm getting old, I want a nice an intuitive interface. I pay to save my time and Postman is really helping with this.

EDIT: I just tested it, still a big MEH. Not sure how big your projects are but I feel this is not suitable for the size of my projects.

Collapse
wabbbit profile image
Rich

We have a lot of REST APIs to test, as well as a lot of variables that need changing on the fly quickly by testers to test certain scenarios. For us, Postman works better. This plugin is ok but we have powershell scripts that can do the same stuff and its not as intuitive.

I get the idea behind this in that it just "fits" into version control etc and in theory its easier to have VSCode installed, but I think there is space for both of these tools. This extension fits nicely for quick dev test stuff, but I think I still prefer Postman for more complex scenarios, plus it has a host of other features.

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Hmm, if it fit you and your team organisation, it can be a solution, for sure :) We're trying here, to avoid to get thousands of tools and be sure to be up to date with "just the repo".

Collapse
nick profile image
Nick Rameau

You must be doing a lot. I use a lot of tools too (I work fully digitally), but I close the ones I don't use right away.

Thread Thread
monisnapjonathan profile image
Jonathan BROSSARD Author

Some ones are always opened you know (IDE, Slack, Database connection, Terminal, Trello, Chrome etc..) hard to be able to close each tool one you're done with.

Thread Thread
nick profile image
Nick Rameau

That's really not a lot. And that's about all I need as a fullstack developer. The terminal is part of VSCode and I use pen and paper for my tasks (with ClickUp for project management). I don't use any messaging app WHILE coding, no distractions.

Even tho I dabble with many parts of the systems I maintain and build, I don't have more than 6-8 apps open at the same time. And this is not even half of the apps I can handle open at the same time.

I feel like we're bringing a problem that does not exist just to justify the use of this tool... and I feel like a hater, so I'll stop at this. ;) I hope it's useful to anyone else. I'll try to get more invested into testing it out in the future.

Collapse
mohdraqif1 profile image
mohd.raqif

It's nice but one thing to consider. You can share the whole workspace of postman either with a single person or with a team, your choice. I think that reduces the pain of editing the source code or it's syntax maybe.😁

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Hi @mohdraqif1 . Yes, you're right, but by putting it into your repo, you can be sure that it's always up to date :) I think that we should never be afraid of updating code/repo.

If we're afraid, it may mean that we are not confident :)

Collapse
thebojan profile image
Jordan Munroe

Holy balls this is awesome! I'm working solo at the moment so keeping Postman up to date has been at the absolute bottom of my priority list... My workspace already has 5 necessary windows up(VS, Server console, Code and Chrome) and having to switch between them is already a nightmare without introducing Postman to the mix.

Being able to test the API without leaving Code would be a godsend! Damn am I happy your article showed up in my feed, thanks a googolplex! I didn't even think about using something other than Postman.

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Hi @thebojan , that's a limit we had with Postman and its workspace... Very happy that we can help you :)

Collapse
liyasthomas profile image
Liyas Thomas

Another addition is our project: Postwoman.io - Online API request builder.

GitHub: github.com/liyasthomas/postwoman

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Hi @liyasthomas , It let you save everything in a file that you can share with your team and version into the project repo ?

ps : but believe me, it's on my favorite (from the time where favicon was an Alien head ;) ) and I often use it !

Collapse
liyasthomas profile image
Liyas Thomas
  • Allows to save Collections / Folders into JSON and share with Team ☑️ COMPLETED
  • Versioning and saving to GitHub repo - Work in progress
Thread Thread
monisnapjonathan profile image
Jonathan BROSSARD Author

Versioning and saving to GitHub repo will be the perfect option :) can not wait to see it !

Thread Thread
liyasthomas profile image
Liyas Thomas

On it. 🌈🌈

Thread Thread
monisnapjonathan profile image
Jonathan BROSSARD Author

Maybe let the Alien face as favicon come back, I have so many favorites but this one, I saw it first each time ^

Thread Thread
liyasthomas profile image
Liyas Thomas

Will consider that ❤️

Thread Thread
monisnapjonathan profile image
Collapse
vonheikemen profile image
Heiker

Glad to know I'm not the only one who refuses to use postman for simple tasks. I actually build myself command-line utility for the most basic use case, that is making a request based of a collection in a json file.

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Hi @vonheikemen , thanks a lot for the sharing !

Collapse
devjonny profile image
Jonny Olliff-Lee

REST Client is such a great tool. We using extensively for the purpose of testing, and sharing examples in our project repos.

The ability to use JSONPath to follow links or grab values from your API response to form the next request is invaluable. Not to mention really great for demonstrating how REST APIs are meant to look and work!

If you've not tried it, give it a go. You need to name your request with:

# @name MyAwesomeRequest

But then once you've invoked it you can access a variable of the same name so {{ MyAwesomeRequest... }} the request and response plus the headers and body for both.

It's only more recently I stumbled across the environments feature, but that's made a huge difference in cutting down the noise of declaring loads of variables that change per environment.

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Hi @devjonny !

Totally agree, grabing values from previous API responses is amazing and let you easily test calls sequences.

Many thanks for this sharing, hope it could help readers to deep dive on this such great extension !

Collapse
alevinetx profile image
alevinetx

Two things that made me leave Postman:
1: i signed in to see what the value-add was, only to discover it ingested all of my collections into an online profile that vanished from local storage when I signed out. I was not expecting that, nor was I thrilled.

2: the (then) attitude that postman developers knew better than its users, and added superfluous request headers with no way to remove them.

it sounds like this would never cause #1 to happen. but, what about #2?

Collapse
cirelli94 profile image
Cirelli

I think the good idea is to have the tests in your repository.
Is there a way to place insomnia/postman configurations in our own repos?
It's not a problem to open another program to me.

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Hi @cirelli94 , yes you can. You could export your Postman calls into a json config file and store it into your repository. But, each time you make an update into Postman, unfortunately, you have to re-export file. You can't just open your versioned json config file into Postman, make your updates, and just make Ctrl+S, it doesn't work, because Postman save it into the Postman application directory.

Collapse
cirelli94 profile image
Cirelli

Mm maybe insomnia?
The problem is that in an office you can't impose a IDE, my coworker would kill me 😆

Thread Thread
monisnapjonathan profile image
Jonathan BROSSARD Author

I understand ^

Don't know about Insomia, as VS Code fit our needs based on our stack, it's for us the best IDE in term of IDE and save a lot of time (versionning, unit tests, integration tests, lint etc..) :)

Thread Thread
nilskp profile image
Nils Kilden-Pedersen

Why can you impose Insomnia or Postman, but not VSCode?

Thread Thread
monisnapjonathan profile image
Jonathan BROSSARD Author

VS Code is pretty perfect for our stack, so actually, if I would change my IDE, I still did not find better. About Postam, Insomnia, I do not impose it to my team, but if I want, in repositories, everyone can share API Calls, REST Client is perfect and free.

Collapse
andreidascalu profile image
Andrei Dascalu

Ford development that is great, but as a generic tool, Postman can export/import curl calls that can be copy/paste to and from terminals
Also, can the env vars be used to parameterize the actual content of the requests? How can certificates be configured?

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Yes it's true that the ability from Postman to generate the command for cURL, Node, PHP, Ruby, Python can be very usefull !

Yes, Auth via SSL Client Certificates is support :)

Collapse
pzelnip profile image
Adam Parkin

Woah, that's super cool. Have found in the past that saved Postman collections are kinda awkward to deal with in a team environment, but with this one could create a saved collection of requests, and then commit that to source control to share. If any of the requests change you just update that file.

Seems to me too it wouldn't be super hard to generate a Postman collection from a file that REST Client uses, so for those teammates that don't use VS Code for whatever reason, you could still have them generate an equivalent collection to use in Postman.

Collapse
juniormayhe profile image
Junior Mayhé

This is interesting, but I would like to see examples of how to use consume an URL (either with Get or Post), grab its JSON response to extract a property like a Bearer token and reuse it in subsequent calls. You can also grab any other piece of information from JSON that you might have such as a user ID, username, whatever and reuse them in further calls. Postman can do that. Would REST Client be able to do it?

Collapse
jakebrandt profile image
Jake Brandt

Biggest pro in my eyes is natural source control integration! Postman has some truly great potential; but what it has lacked for me is file-level source control. Postman offers Git integration; but it's not within your existing repos - therefore you can't easily pair source code versions with sample HTTP request versions.

Collapse
katafrakt profile image
Paweł Świątkowski

Cool, I didn't know that. One problem I see: we were able to teach some of our non-programmers colleagues to use Postman to some extent. But I don't see them learning how to use VSCode for that ;)

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Yes you're right. But pretty okay here because the purpose is to share API calls between developers team :)

Collapse
hituraj profile image
Hitesh Singh

I am getting below error while posting the call

write EPROTO 1215459160:error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER:../../third_party/boringssl/src/ssl/tls_record.cc:242:

Collapse
josephmhlanga6 profile image
Joseph@CST

Check if u not trying to call yr API using https when it supports http

Collapse
luiszuluaga profile image
Luis Zuluaga

Are you using https instead of http? Maybe this is the problem

Collapse
ladipo profile image
Ladipo

Try to use http after your request. e.g GET localhost:3000/articles HTTP/2.0
I have the same error until i use this.

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Looks like it come from API you're trying to call no ?

Collapse
mostafiz93 profile image
Mostafiz Rahman

It's great to call REST requests from VSCode. I've just tried and it worked well with a limitation. In the response panel it only shows a single response(response to the last request) although there are multiple requests in the .http file.

Collapse
hyde_stevenson profile image
[mastodon] Hyde Stevenson

And for those using vim, you can use something like this :

github.com/diepm/vim-rest-console :)

Collapse
monisnapjonathan profile image
Collapse
hyde_stevenson profile image
[mastodon] Hyde Stevenson

You're welcome :)

guneyozsan profile image
Guney Ozsan

Actually unused RAM is wasted RAM. This stil doesn’t not explain slowness of Postman.

Thread Thread
victoryarema profile image
Victor Yarema

Usually people treat RAM that is being used by OS for permanent storage data cache as free. That is just soo wrong.

Collapse
gergelypolonkai profile image
Gergely Polonkai

We could easily use it if this add-on would be compatible with restclient.el (an Emacs package with a similar purpose), as both editors are widely used at our company. But in this way, it’s just another way to do the same thing…

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

We do not want create a standard... just show an easy way to share infos between colleagues ;)

Collapse
beelzenef profile image
Elena G

sounds good, thanks!

Collapse
monisnapjonathan profile image
Collapse
leob profile image
leob

Fantastic, most of the time I reach for curl (rather than Postman etc) to do this kind of thing, but this looks great, and potentially easier than curl

Collapse
swiknaba profile image
Lud

I usually like having to use less tools, but I disagree for one reason: text editors are a very personal choice, plus this choice changes from time to time (I've been through many different text editors). So this will lock you and the entire team in one text editor.

Besides, you can also export your postman collection into one json file and put that in version control, no need for the payed plan. Other tools (insomnia) are able to import that => maybe it's compatible with VS code? That'll be nice.

I would not (easily) join a team, that forces me to use one particular text editor ;)

If you really want to cut tools, how about curl?

You can also auto-generate a OAS3 compliant API documentation, which you can use to, well, have a documentation, and also use it with curl. Or render it in the browser and build a little UI that allows you to fire requests from your browser. Serve that documentation file from your server, and also the frontenders can render the UI to make requests without having to run the API on their local machine.

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

I understand your point.

Export Postman collection exposes you as the fact that you always need to do that (Postman don't auto save into your repo) and it's pretty boring.

The main point here is to be able to maintain it into a repo, without need another tool. It could be a shell script which make cURLs... but can be a pain in the @$$ to get all available features you'll find with REST Client, into a simple shell script.

I fully understand your point about the IDE. Really. In my case, I use during many years Emacs, then Sublime Text, and did not want to get a big IDE. But I opened VS Code and many others, and check the time saved ... based on our tech stack, currently VS Code seems to be the best choice.

I we would to have a final word, we could say that the better world is a .yml file to get a swagger

Collapse
renodesper profile image
Boy Sandy G. A.

One think that I really like about postman/similar app is the history. Trying a different authentication/query params/payload will be hard if we have to constantly undo and redo the changes.

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Yeah, agree ! History is a great feature !

Collapse
jayrald07 profile image
Jayrald Empino

Nah! I'll go with Postman. It has a great features for sending and receiving a response. But, thanks for sharing, maybe I will use that in some situation.

Collapse
crisdan1905 profile image
Cristian Danilo Gutiérrez

Great article, I'm only confused about how to set environments. I can't find any guide to set environments (not even in the extension documentation). Can someone help me please???

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

Hi @crisdan1905 ,

Don't you find more info event under "Environments and custom/system variables support" section in marketplace.visualstudio.com/items... page ?

Jon

Collapse
crisdan1905 profile image
Cristian Danilo Gutiérrez

Hi Jon, it's just that I hadn't worked with environment variables before on VSCode, so I had no idea how to create an environment file and VSCode documentation about it was a bit confusing to me. Finally, I figured it out in another guide. It may be useful to explain how to create the file in your documentation :)

Great tool by the way, I just loved it and will keep using it

Collapse
offero profile image
Chris

Love REST client!

Collapse
princebillygk profile image
Prince Billy Graham Karmoker

I still love postman. It have some other features too 😄

Collapse
alexkapustin profile image
Oleksandr

imgs.xkcd.com/comics/standards.png

Why file? Why don't use already existing standards ? For example: swagger.io/docs/specification/about/

Collapse
monisnapjonathan profile image
Jonathan BROSSARD Author

I fully understand your points, but REST Client have some interesting features like requests sequences, variables handling and it's easier to edit and click to play request on the same file that update your yaml and then execute the swagger.

REST Client, in my point of view, is NOT an OTHER NEW standard, just a cool tool to ease team work.
It's not a way to replace a swagger, and it wasn't my point :)

Collapse
alexkapustin profile image
Oleksandr

Are you planning to have functionality to have collections? Basically saying, saved request interfaces and ability to import from swagger/openapi/soap/etc ?