function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sunil Kumar 545Sunil Kumar 545 

how to create contact using URL parameter (id,name,email),if contact id is empty it must throw exception erorr using JSON method in HttpPost method apex class

SandhyaSandhya (Salesforce Developers) 

In Post method to throw error you can use response.Status = 'Success';
response.ErrorCode, response.Message.

Refer below link which has sample code for the same.
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
Best Regards
Shubham NandwanaShubham Nandwana
Hi Sunil,
You can retrieve URL parameters in salesforce using 
String paramValue=ApexPages.currentPage().getParameters().get('myParamName')
You can check for exception handling in rest.
You can also use custom exceptions to show error, refer to
Hope it helps, mark it as solved if it does.

Shubham Nandwana.
AppPerfect Corp.
Salesforce Development & Operations Experts