HTTP Requests in Your Favourite Language

Our code generators just got better

Thu Aug 03 2017 14:22:28 GMT+0100 (BST)

One of the advantages of the Suite's HTTP request capabilities is that not only does it offer easily customisable HTTP requests, but also it has abilities to write equivalant code in your favourite programming language. For example, you can customise your request, translate it into curl and directly execute it in the terminal. Neat, right? Today, we introduce several new code generators so that you can directly copy-paste these requests into the software you are building.

How does it work?

Create a request to you liking. Once done, select a language from the dropdown below (by default, http is selected)... And you are done! Simple! And the best thing is that this feature is accessible by all tools that deal with HTTP.

I just want to touch upon a few things about the generators, mainly related to the technologies they are using.

Python

The generated code for Python uses Reqests library, which nicely abstracts away from the complexity of HTTP requests. In the future we will add support for vanila Python as well.

Ruby

Our solution for Ruby makes use of the built-in net/http lib, ensuring compatibility with every user of the language.

Java

The Java code generator defines a class together with main method so that the created request can be executed immediately. As for the technologies - only core Java libraries are used.

JavaScript

For Javascript, we have chosen jQuery's ajax method as a simplification over using the XMLHttpRequest object. Keep in mind, though, as you are working in a browser, there is a set of header keys that cannot be set ('Cookie' or 'Host', to name a few).

Conclusion

Imagine you are getting the gist of a third-party API that you plan on using in your app. Hand-tailor the request in Rest. Once you are satisfied with the result the server returns, use the code generator for the language your app uses and just copy-paste the generated code in your source. Done! You've just found your way around this new API without writing a single line of code. And this is simply one of the uses of the new code generators - I leave the Rest (no pun intended) to you to explore!