Tool Tip: Testing REST Services
I came across this very useful plug-in for Firefox that helped me troubleshoot why my RhoConnect Source adapter was not working with the REST service I was trying to sync data with. It's naturally called RestClient and not only is it super easy to use, it has some very cool features. I tend to use Chrome as my browser of choice and at the time thought I had a plugin that helped with testing REST, but RestClient for Firefox seems to do it all. Of course it does the basics like all of the flavors of requests (PUT, POST, GET, etc) as well as seing detailed request and response body. But it also lets you very easily add Authorization and Header information with a few clicks. Let's me give you a quick tour.
After you install Firefox, install the plugin by going to this URL and clicking Add to Firefox.
Once the RestClient plugin is installed, look for the icon in the toolbar:
You see that there is a drop down for the type of request you are making as well as a place to put the URL of where the request should go:
Then, like in my case, all of my REST calls require Basic Authentication. For this, you simply click the Authentication menu item and select Basic Authentication (it also supports OAuth)
I can then make a simple GET request and see the response headers and body.
The problem I was initially having was that my call to the REST service did not have the right Content-Type in the header of the request. The RestClient plug in allows you to easily add header information:
Then you start typing the type of header and it auto-suggests the correct spelling of common header names and values. In my case I thought a Content-Type:application/json was the right request header, but in fact my problem was that I needed application/x-www-form-urlencoded. It also let's you save this header to your favorite headers for quicker selection later.
Once you have you request put together, you can save the whole request to you favorites:
Once I had my REST communication working by testing it out using this plug in, I then was able to test it out in IRB to make sure my Ruby syntax was correct.
After verifying my REST + Ruby was working, I then was able to complete my RhoConnect source adapter without much trouble. I hope that you find this tool useful as I have. If you have suggestions for other tools and techniques that could be helpful in troubleshooting your RhoConnect Source adapter, please add your comments.
Robert Galvin