July 8, 2011 Testing Apex REST Services with Apigee Console

Since we are spinning up more and more challenges using the Apex REST service (like the Member Service and Challenge Service challenges), I thought it might be good to put together a couple of pointers on developing with it.

The first tip is that the Apex annotations only work with v22 of the salesforce.com Api. So you will receive an error if you try to save an Apex class like below.

@RestResource(urlMapping='/AccountService/*')
global with sharing class AccountRestSvc {

@HttpGet
global static Account getAccount(RestRequest req, RestResponse res) {
return [select id, name from account limit 1];
}

}

In Eclipse, you’ll need to open the associated XML file (in this case AccountRestSvc-meta.xml), change the API version to 22 and then commit the file back to the server.

Another tip is to use the Apigee console to test your REST calls. This tool is invaluable and make developing fun since it will do the OAuth for you. Check out the video below and then hop over to the Apigee console to get started.

The URL to use to call the REST service should look something like: https://[instance].salesforce.com/services/apexrest/[urlMapping]




UNLEASH THE GIG ECONOMY. START A PROJECT OR TALK TO SALES
Close

Sign up for the Topcoder Monthly Customer Newsletter

Thank you

Your information has been successfully received

You will be redirected in 10 seconds