We have exposed an Apex Class as a Rest Resource. It is a HTTP Post class and broadly it has the following logic:
- Get parameters to create a new Account
- Validate if existing database if it is a duplicate
- If yes, throw error.
- If no, create Account and return the Salesforce ID of the Account.
The response is returned in a JSON format. What I want is to also be able to set the HTTP Response Status parameter. It is by default set by Salesforce as 200 but I want to set it based on various conditions in my logic (For e.g.: 400 in step 3 on above logic).
Is this possible?