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
2. Supply the proper path: http://localhost:8080/alfresco/service/api/sites/%7Bshortname%7D/memberships?nf={namefilter?}&rf={rolefilter?}&size={pagesize?}&pos={position?}
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.
You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

How do I get the REST client to use JSON instead of XML?
In the request-header be sure you are using Content-Type= application/json. Also make sure that the REST server you’re contacting provides support for json.
Thanks for the example.
Can you please also show how PUT and DELETE can be tested. I tried REST request DELETE and I get:
“Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request. “
You need to verify that the server can handle DELETE and PUT requests first. An internal server error could have a plethora of different causes and would be hard to debug without additional information. Take a look at the wadl for the server you are making calls to. This should tell you what types of requests are available.