0

I am working on a rest class and have created different type of rest service with a defined URL. However, I was just going on a requirement and looking for the possibility regarding:

Inside same apex rest class with same URL Mapping , Is there possibility to have 2 post method:

  • 1 for delete
  • 2 for update
2

Each HTTP verb can only be used once per URL. You can use a @HttpPost and @HttpDelete method in the same class. When calling the service, use the appropriate verb (POST or DELETE).

  • Yep i know But just In case of any requirement is there any feasibility to have 2 post one for delete and one for update as any workaround. – cloudy-ritz Jul 18 '17 at 17:41
  • 2
    @cloudy-ritesh you should use the appropriate verbs. Not doing so is a violation of RESTful principles. You also can't call two different methods directly, because the server would have no way to determine which one to call. If you really to do it anyways, you'll need to write all the logic in one method using if-else logic. – sfdcfox Jul 18 '17 at 17:47
  • 1
    Yeah, definitely use the right verbs. A developer integrating with your system would be justifiably irate to find out their POST request deleted something. – Adrian Larson Jul 18 '17 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.