Skip to content

Instantly share code, notes, and snippets.

@nickforce
Created November 21, 2019 23:36
Show Gist options
  • Save nickforce/a6857c994e5d155888c991934b8871a6 to your computer and use it in GitHub Desktop.
Save nickforce/a6857c994e5d155888c991934b8871a6 to your computer and use it in GitHub Desktop.
@RestResource(urlMapping='/xxxx/*')
global with sharing class MyWLResource {
@HttpPost
global static void doPost(String accountid)
{
Account myaccount;
list <Opportunity> myresult;
try
{
myaccount = [select website from Account where id=:accountid];
myresult=[select id from Opportunity where website__c=:myaccount.website limit 10];
RestContext.response.addHeader('Content-Type', 'application/json');
RestContext.response.responseBody = Blob.valueOf(JSON.serialize(myresult));
}
catch (Exception e)
{
RestContext.response.addHeader('Content-Type', 'text/plain');
RestContext.response.responseBody = Blob.valueOf('Incorrect account id');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment