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

This blog is permanently closed.

For up-to-date information please follow to corresponding WebStorm blog or PhpStorm blog.

 
This entry was posted in Cool Feature, PhpStorm and tagged , , , , . Bookmark the permalink.

49 Responses to Using the REST Client within PhpStorm and WebStorm

  1. Zyava says:

    Text on screenshots is almost unreadable :(

  2. Nicole Cordes says:

    Would be cool if you have the opportunity to define the method to be sent to the server as for example a Varnish system you need PURGE and/or BAN method (usually). Is there any way to extend the methods?

  3. AVEbrahimi says:

    Seems useful!

  4. Marco says:

    Looks nice, but what about Webstorm? Modern Web Apps are using REST services very heavily!

  5. Christoph Walcher says:

    Will this feature be available in webstorm too? Seems quite useful for node rest API development…

  6. Maciej says:

    Hi,
    Very good tool. However ;) if there’s function to store a different request and select them to run test against different services quickly I won’t have to run JMeter too often :)
    Regards,

  7. Andreas Eigenmann says:

    +1 for Support in WebStorm. Very very useful for node.js development!

  8. That’s a cool feature! It would be nice if it would be coupled with debugging somehow.

  9. Soz Nov says:

    Nice.
    But, what about http basic authorization?

    • Konstantin Bulenkov says:

      You have to do it manually now. But that’s a good idea to make it as simple as entering your credentials. Could you please file a feature request?

  10. Igor Sutton says:

    This would be useful in AppCode as well.

  11. ksafonov says:

    REST client with be included in WebStorm installation since the next public build (essentially tonight)

  12. Fabio says:

    What about other IDEs? I’m using PHPStorm and RubyMine, will this (very useful) feature be included also in other products?

  13. Kiview says:

    Will this be or is this available as a plugin for IDEA as well?

  14. Bertrand Dunogier says:

    Good addition. But unless I’m mistaken, it is not possible to save preconfigured requests, is it ? This would really make it more useful.

  15. How about for testing API’s that require authentication?

    • Bertrand Dunogier says:

      You can manually add the headers your API will use, depending if it’s cookie, basic, oAuth…

      Higher level integration would of course be better ;-)

  16. Maarten Balliauw says:

    Feel free to request a feature in the issue tracker at http://youtrack.jetbrains.com/issues/WI

  17. Pingback: WebStorm 6 Public Preview Build | WebStorm & PhpStorm Blog

  18. Arno.Nyhm says:

    Yes! IDEA and RubyMine and AppCode would be nice

  19. This is really exciting that you’ve provided this REST Client. I just tried it out and I’m hopeful.

    However, there are two things that I think it really needs, and one is an obvious deficiency:

    1.) It needs to be able to trigger the PhpStorm debugger so that we can trace through the code implementing the web service.

    2.) It also needs a way to save off a “session” complete with method, host/port, path, headers, query parameters and request body. What would be awesome is if the rest client could be configured to look in a directory for JSON files that would contain this information which would allow us to save them using the UI and/or to edit or create them by hand using the editor or even in an automated fashion.

    I’m going to add both of these as feature requests.

  20. Pingback: WebStorm 6 – HTML5/CSS3/JavaScript IDE now with TypeScript, CoffeeScript and Dart support | techscouting through the java news

  21. Arash Dalir says:

    Has anybody tried to upload a file with this really helpful extension? I’m capable of uploading the file and the $_FILES gets filled, but the problem is that in the $_FILES array, each entry name must be relevant to a field name on the form, and there seems to be no way to define the field name for the uploaded file in this extension. Or is it? Could anyone tell me how to bind an uploaded file to a specific field name?
    Also, is there anyway to upload multiple files at the same time?

  22. Christian Tonka says:

    Seriously, why do most rest clients not offer the ability to set Basic authentification data directly. It is really not convenient to base64 encode the username:password myself every time I want to try something out. And a lot of modern APIs require this information.

  23. Pingback: Новости » Blog Archive » Новый PhpStorm 6.0 облегчает работу с Composer и другими инструментами

  24. Pingback: Новости » Blog Archive » Новый PhpStorm 6.0 облегчает работу с Composer и другими инструментами

  25. Pingback: Новости » Blog Archive » Новый PhpStorm 6.0 облегчает работу с Composer и другими инструментами

  26. Sapher says:

    Hello everyone. I spent the whole day to use the brand new REST Client tool, But I think something is missing. In the response headers, I can’t see the HTTP Status code, Is there a way to get it or this feature doesn’t exist at all?

    • Mikhail Vink says:

      I can see the HTTP Status code under the Response box (Response tab) e.g. “Response code: 200(OK); Content-length….” or in Response Headers tab e.g. “Status: 200 OK”.

    • Adrian Rudnik says:

      As stupid as it sounds, I got the same error yesterday. Clean PhpStorm installation on Windows and I gave up. Today i figured out that the REST Client tool is not sized correctly in height. You have to drag it a bit up to see the bottom line containing the status response code. The only reason why I noticed that: the outputs seemed to be truncated at the end (last line was always missing) and there is NO indication that there is more content at the bottom of the tool.

  27. Pingback: Дайджест интересных новостей и материалов из мира PHP за последние две недели №24 (11.08.2013 — 25.08.2013) | Juds

Comments are closed.