6 ms·
As I have also been frustrated with the direction Postman has taken, I have a great alternative to suggest, if the only thing you want to do is fire requests on
by avel 5y ago
As I have also been frustrated with the direction Postman has taken, I have a great alternative to suggest, if the only thing you want to do is fire requests on demand easily and do not need automated testing.
The VS Code Rest Client extension https://marketplace.visualstudio.com/items?itemName=humao.rest-client https://marketplace.visualstudio.com/items?itemName=humao.re... is great for testing and debugging APIs.
You create a "my_request.http" file that contains something like
POST https://example.com/comments HTTP/1.1
content-type: application/json
{
"name": "sample",
"time": "Wed, 21 Oct 2015 18:27:50 GMT"
}
First line is the method and url, then headers, then a newline, then the request body.
Hit ctrl+alt+p, the request is sent and you see the response in a side pane. Everything is encoded and decoded properly.
You can organize your tests under multiple files and folders.
I cannot recommend this extension enough, it has made my life so much easier.
- judge2020 5y agoCan it do substitution with some sort of application-based KV store? The main reason I used a rest client like Insomnia is so that I can reference secrets like {{ client_secret }} or {{ api_key }} and have a change to the value in the KV store reflect for every request.
- nexuist 5y agoYes, it seems like it: "We support two types of variables, one is Custom Variables which is defined by user and can be further divided into Environment Variables, File Variables and Request Variables, the other is System Variables which is a predefined set of variables out-of-box." However, what I can't figure out is if it supports programmatic variable setting. I have an API where I need to retrieve a token from an endpoint before using it for every other endpoint, and I'm using Postman's test scripts to set that token as an environment variable before sending all the other requests so they can all use it. I don't see a way to replicate that with this extension.
- test-account 5y agoYou can do it with intelij
- cloudrkt 5y agoYes it supports variables, don't know about KV store, see: https://marketplace.visualstudio.com/items?itemName=humao.rest-client https://marketplace.visualstudio.com/items?itemName=humao.re...
- halpert 5y agoDoesn’t curl do this just as easily?
- IshKebab 5y agoSounds a lot easier than curl tbh. No need to deal with shell scripts and their insane quoting, plus you get the response straight in your editor with syntax highlighting.
- halpert 5y agoMaybe it’s just me but I’ve never had those issues. Another benefit of curl is that you have an easily searchable history of every command you’ve run. So you can easily find old invocations and rerun them.
- avel 5y agoThis extension also keeps a history of requests. How complicated are your requests? If I need to test a POST request with a JSON payload longer than a line or two, I'll go and construct my curl command in a text editor anyway, since the shell prompt / readline is not easy to edit. Once you need to start escaping single or double quotes or html payloads in the request, it quickly gets cumbersome. At that point I ditch the shell as a middleman and use the editor to submit the request for me.
- avel 5y agoSomeone posted https://hurl.dev/ https://hurl.dev/ below. It looks like a command-line alternative to this, with a similar format, and support for assertions.
- jicea 5y agoHi, one of the maintainer of Hurl [1]. It is effectively basically just curl (we're using libcurl under the hood). I would say that we have added the ability to chain request (you could use curl in a shell script), and a bunch of assert (like jsonpath, xpath etc...) on response (which you could arguably do also with shell script). We also wanted something text based, that could easily be integrated in a CI [2] for instance. We are using Hurl to test our web application (~2M unique visitors/month). Very happy with it currently, but there are really a lot of very good tools in this space (as we can see in these comments). [1] https://hurl.dev https://hurl.dev [2] https://hurl.dev/docs/tutorial/ci-cd-integration.html https://hurl.dev/docs/tutorial/ci-cd-integration.html
- sharat87 5y agoShameless plug: There's also Prestige at https://prestigemad.com https://prestigemad.com, which is very similar but works right in the browser. You can save your files as Gists as well. Templating with variables is also supported with `${}` syntax, like Javascript's template strings. But gRPC support is not built yet. It's on the roadmap.
- nichos 5y agoThere's also insomnia: http://insomnia.rest/ http://insomnia.rest/ Which is an open source, cross platform alternative to postman.
- Cthulhu_ 5y agoI too like this approach, because the format is simple and text-based and you can maintain it in your git repository. My main gripe with Postman and Insomnia isn't actually the web based UI, but the lock-in. You can't access the files that they store their data in easily. Postman especially tries to push people towards getting their per-seat 'cloud' subscription if you want to share sets of HTTP requests. But using this text-based REST client, you don't have this file lock-in. For IntelliJ this feature is actually built in, I believe it uses the same syntax.
- seanw444 5y agoFor you Emacsers that haven't heard of it, the alternative to this https://github.com/pashky/restclient.el https://github.com/pashky/restclient.el Super straightforward.
- saikatsg 5y agoAlso, Thunder client is a lightweight REST API client extension for VS Code. Good fit for basic usage requirements.