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 ?
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 :
And by clicking on "Send Request", a new tab with all request response details will be opened.
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 !
Oldest comments (113)
Many thanks @ankush981, indeed, probably one of the best reason : "why open another RAM-hungry app" !
Ram-hungry? Equipment is cheap compared to salaries these days running out of ram should just not happen even with swapfile disabled
Maybe some people play games while building the app and testing lol
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 ...
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....
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.
Yeah, lagging will mess my mood. if it's not 60fps then I'll not code hahaha just kidding 😂
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.😁
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 :)
sounds good, thanks!
Thanks @beelzenef !
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.
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.
Mm maybe insomnia?
The problem is that in an office you can't impose a IDE, my coworker would kill me 😆
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..) :)
Why can you impose Insomnia or Postman, but not VSCode?
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.
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.
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 !
curl. That's all.
😄
Is there a version of this for Jetbrains??
Hi @alejandrorios ! Did you already check jetbrains.com/help/idea/http-clien... ?
😮 I didn't know it, thanks
💪
Insomnia.
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.
Hi @thebojan , that's a limit we had with Postman and its workspace... Very happy that we can help you :)
For linux users we don't need any rest client because cURL is more easy
There's curl for windows too, but rest client is quite different thing in a team development perspective
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:
Looks like it come from API you're trying to call no ?
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.
thank u
Are you using https instead of http? Maybe this is the problem
Check if u not trying to call yr API using
https
when it supportshttp
thank you
Been using it for a while now and I must say it very convenient having your tests right there.
It’s also simple and quick to use.
🙂
Another addition is our project: Postwoman.io - Online API request builder.
GitHub: github.com/liyasthomas/postwoman
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 !
Versioning and saving to GitHub repo will be the perfect option :) can not wait to see it !
On it. 🌈🌈
Maybe let the Alien face as favicon come back, I have so many favorites but this one, I saw it first each time ^
Will consider that ❤️
😍
"Versioning and saving to GitHub repo - Work in progress"
Didn't see an issue to follow for this. Is it complete now? Thanks
Niiice!
Thanks @faridos :)
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?
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 :)