Often times I find myself needing to test various calls to Alfresco’s RESTful API. There are several way to do this, I had chosen to use curl to do most of my testing until a coworker showed me a great new toy. There is a firefox add on that acts as a REST client with a simple interface that makes testing calls fast and easy. In the GUI you can set login credentials, request headers, and a request body.
To better show off the ease of use this tool provides lets do a couple calls against a running instance of Alfresco. Using the membership interface lets run a call to give us the members of share site.
1. Set the call type to GET
The shortname for my site is “myfirstsite”. I have a few other options which can be used to filter the result set. Since I am using a small site I’m not going to apply any of these. Here is what my call will look like
3. Add login credentials for the repository. Hit the login button, select basic and enter your information.
Since we’re just requesting information we do not need to do anything else. Here is what the client looks like with the information filled out:
Hitting send will give you a response from the server. The status code will be green or red based on success or failure. Hitting the response body tab will show you the unformatted response from the server. There is also an option to view the response as formatted JSON.
It looks like it is working correctly. In the response body I can see information on the members of “myfirstsite”.
Lets try adding a member to the same site. To do this we will change the method from GET to POST. We are also going to add a request header with the content type we are sending. This allows to the server do decipher the body of the request properly. Finally, we will add the request body with the new user’s information. Keep in mind this needs to be a user that is already in the system. If you want to verify your JSON formatting you can do that with JSON Lint.
If you get the green light here is what the request and response will look like:
I have successfully add user1 to myfirstsite. Hope everyone finds this great tool as handy as I have.