Using the REST Client within PhpStorm and WebStorm

When building REST-based web APIs, it’s worth having a tool available to invoke them over HTTP. The current versions of WebStorm 6, PhpStorm 6, RubyMine 5.4 and PyCharm contain a bundled REST Client plugin which allows us to do just that.

In this blog post, we’ll have a quick look at the built-in features of the REST Client and on how to use them.

In this post, we’ll be using PhpStorm as our IDE, invoking an API built using the Silex framework which is similar to frameworks like Sinatra and Nancy. The API we’ll be testing using the REST Client plugin is fairly straightforward: it exposes an array of users through a REST endpoint. The /users endpoint returns the entire array of users. The /users/:id endpoint returns a specific user when issuing a GET request and writes a user to the array when issuing a PUT request. The source code for this API is available as a GitHub Gist:

The REST Client can be found under Tools | Test RESTful Web Service. A new tab will be opened which gives us the possibility to craft an HTTP request which will be invoked against our API. We can specify the HTTP method to be used, the host where our API is located, and the path to be invoked. Other than that, we can add header data as well as query string parameters or a request body to be sent to the API.

Upon invoking the request by clicking the green Run button, the REST Client connects to our API and gathers the response data. We can easily inspect the response body as well as the response headers, each available through their own result tab.

To create a user in our API, invoke a PUT request providing JSON data in the request body. We can provide the request body by entering the text or by selecting a file to upload as the body.

Download PyCharm, WebStorm 6 Preview, or the latest PhpStorm 6 EAP build and let us know what you think!

Develop with pleasure!
– JetBrains Web IDE Team

About Maarten Balliauw

Maarten Balliauw is a Developer Advocate at JetBrains, working on .NET tools. He focuses on .NET, Azure, web technologies and application performance. Maarten is a frequent speaker at various national and international events. In his free time, he brews his own beer. Follow him on Twitter or check his personal blog.
This entry was posted in Cool Feature, PhpStorm and tagged , , , , . Bookmark the permalink.