Multiple APEX REST methods with HttpPost annotation – how to selectively invoke with REST client (e.g. Postman)

I have a class which consists of Post annotation with two methods under it.These methods will be called based on some criteria and they vary by the count(number) of parameters i.e. one method has two and other has three parameter.So when performing this post method from post man how to call the particular method without doing any check conditions i.e. number of parameters and then passing control to the method based on parameter.

Answer

You can’t “overload” rest methods. Each method must map to exactly one function.

You’ll have to either use two functions with different names, or one method that checks the number of parameters and makes the appropriate function call.

Attribution
Source : Link , Question Author : Manoj Chandran , Answer Author : sfdcfox

Leave a Comment