Created
November 21, 2019 23:36
-
-
Save nickforce/a6857c994e5d155888c991934b8871a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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