I wanted to post this, as I’ve been using the free Insomnia client for RESTAPI testing for some time now and I think it can help with some of the common REST issues I’ve seen here. Insomnia is available at https://insomnia.rest
After installing, begin by setting up an “Environment”. An “Environment” contains a collection of variables that will then be useable in queries.
With those variables set, you’ll be able to supply those as parameters when you set up RESTAPI queries. What makes this useful is you could set up one Environment for Development, another for Production, and then use the same queries in both environments to support testing & production efforts. The values for base_url, user_name, and user_password will be supplied based on which Environment is selected when you run the query.
Next, create a new Request
Give the request a Name, and start off with the type of “GET”. Here’ I’ve named mine “Test_Session_Relevance”.
In the “GET” URL at the top, enter the URL which can include the variables we defined earlier in the Environment. For instance when I typed in “base_url”, a selection box appeared to let me use the stored variable. On the “Auth” tab, select “Basic” and enter the user_name and user_password variable names; again, typing those names generated a pop-up to select the variable definitions.
In the “Query” tab, you can create the different RESTAPI parameter/value pairs you wish to send in the query. You can also check the boxes for each parameter to include or exclude those for the query. Here I have two “relevance” parameters, but only “now” is selected. I’ve also included the parameter “output=json”. Hit the “Send” button beside the URL, and the result appears in the pane on the right.
Switching over to the “relevance=number of bes computers” query, we can see something neat that happens - the query gets URL-encoded automatically! URL-encoding is the number-one problem I see happening in forum posts when people are having trouble with RESTAPI queries.
Once you’re happy with the query, there are a number of neat things you can do. For instance, you can click the drop-down on the Test_Session_Relevance query in the left pane, and “Copy as Curl”. This copies the Curl command into the clipboard; when you paste into Notepad, you get
curl --request GET \
--url 'https://bes-development-server.com:52311/api/query?output=json&relevance=number%20of%20bes%20computers' \
--header 'authorization: Basic [encoded-auth-header]'
Alternatively, you can have it generate code as Node.js, Python, Java,…total of 13 languages.
More useful things…via REST you can call the Client Query API. This actually sends a client relevance query to the targetted clients. This is similar to writing an Analysis, but is a one-time query and gives a much faster response. Set it up using resource POST, with base_url/api/clientquery and fill in details in the “XML” tab
The query ID appears in the results on the right-hand tab after you ‘Send’ the query. You can retrieve the results by adding a GET resource for base_url/api/clientqueryresults/[query-id]
Hope someone out there finds this helpful, and if you already have a favorite RESTAPI client, let me know what you prefer! This is basically one of the first free ones I came across after someone showed me what was possible in Postman (which was much less free).