Professional Documents
Culture Documents
APEX
(APEX WEB SERVICES)
Exercise Guide
EXERCISE GUIDE
Apex Web Services
Table of Contents
Exercise 2-1: Integrating with Custom Apex REST Web Services ............................................ 1
EXERCISE GUIDE
Apex Web Services
Instructions:
1. Modify an Apex class to make it a custom Apex REST Web Service.
A. Log into your org if you are not already in it.
B. Select Setup | Develop| Apex Classes.
C. Click Edit in the Action column next to CandidateKeyRESTService.
i. Complete TODO #1 on line 1 to indicate the class is a rest resource with the
urlMapping of /Candidate/JobApp/*.
ii. Complete TODO #2 on line 5 to indicate the method will process POST requests.
D. Click Save.
2. Determine a position ID to use for testing.
A. Select the Positions tab.
B. Choose Open Approved Positions from the View drop-down menu.
C. Click DBA.
D. From the URL for the page, copy the position ID and paste it in a notepad or other
document.
3. Call the REST Web Service using Workbench.
A. Log in to Workbench.
i. Open a new tab in your browser.
ii. Enter the URL: https://workbench.developerforce.com/login.php
a. Choose:
Environment: Production
API Version: (choose the latest available version)
b. Select I agree to the terms of service.
c. Click Login with Salesforce.
d. If prompted, click Allow.
B. Select utilities | REST explorer.
C. Fill in the values as follows:
HTTP method: POST
URL: /services/apexrest/Candidate/JobApp
Request Body: (make sure to put in your position ID. It should look like
"a05B0000000nLfh")
{
"posId": "<your position id>",
"c": {
"Email__c" : "jsmith@smith.com",
"Last_Name__c" : "Smith",
"First_Name__c" : "Joe"
}
}
D. Click Execute.
4. Verify your call worked.
A. In Salesforce, click Job Applications.
B. See the new Job Application listed under Recent Job Applications.
Review
1. What are the benefits of using custom Apex REST Web Services?
2. What are some limitations when creating an Apex REST Web Service?