Skip to content

Instantly share code, notes, and snippets.

@jeffdonthemic
Created March 21, 2012 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffdonthemic/2146052 to your computer and use it in GitHub Desktop.
Save jeffdonthemic/2146052 to your computer and use it in GitHub Desktop.
MemberRestSvc - Apex REST Service (v24)
@RestResource(urlMapping='/v.9/member/*/results/*')
global with sharing class MemberRestSvc {
@HttpGet
global static ReturnClass doGet() {
String[] uriKeys = RestContext.request.requestURI.split('/');
// get the member name from the uri
String memberName = uriKeys.get(uriKeys.size()-3);
// do awesome programming stuff here & catch any exceptions
try {
List<Contact> contacts = [Select Id From Contact where member_name__c = :memberName];
return new ReturnClass('true', 'Query executed successfully.', contacts);
} catch (Exception e) {
return new ReturnClass('false', e.getMessage(), null);
}
}
global class ReturnClass {
global String success;
global String message;
global List<Contact> records;
global ReturnClass(String success, String message, List<Contact> records) {
this.success = success;
this.message = message;
this.records = records;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment