Skip to content

Instantly share code, notes, and snippets.

@kbs5280
Last active March 20, 2019 15:57
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 kbs5280/fe5f06f1511e32c09798ec631fd12e01 to your computer and use it in GitHub Desktop.
Save kbs5280/fe5f06f1511e32c09798ec631fd12e01 to your computer and use it in GitHub Desktop.
Apex REST Web Service
@RestResource(urlMapping='/Model2WebService/v1/*')
global with sharing class Model2WebService {
@HttpPost
global static void Model2ApiService() {
// Model2ApiService requires a Lead or Account ID to run
// endpoint: /services/apexrest/Model2WebService/v1?targetId=<Lead ID>
RestRequest request = RestContext.request;
String targetId = request.params.get('targetId');
List<Id> targetIds = new List<Id>{};
targetIds.add(targetId);
Model2ApiService.run(targetIds);
RestResponse response = RestContext.response;
response.addHeader('Content-Type', 'application/json');
response.responseBody = Blob.valueOf('{ "Model2ApiService" : "EXECUTED" }');
response.statusCode = 201;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment