You are on page 1of 5

INTEGRATING WITH

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

Exercise 2-1: Integrating with Custom Apex REST Web Services


Scenario:
Universal Containers would like an integration to Salesforce that uses a custom Apex REST
Web Service to input Candidate and Job Application data into Salesforce in a single
transaction. This ensures that the updating of data either fails or succeeds as a single unit,
rather than executing multiple API calls.
Goal:
Create a REST Web Service in Apex that allows you to control transaction management.
Tasks:
1. Modify an Apex class to make it a custom Apex REST Web Service.
2. Determine a position id to use for testing.
3. Call the REST Web Service using Workbench.
4. Verify your call worked.
Time:
15 minutes

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.

©Copyright 2016 salesforce.com, inc. All rights reserved. 1


EXERCISE GUIDE
Apex Web Services

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?

©Copyright 2016 salesforce.com, inc. All rights reserved. 2


EXERCISE GUIDE
Apex Web Services

2. What are some limitations when creating an Apex REST Web Service?

©Copyright 2016 salesforce.com, inc. All rights reserved. 3

You might also like