I want to expose a Rest service class with a method with @HttpPost annotation. Below is the code snippet for what I am doing

global class Services {
    global static String createNewCase() {

     return 'Done';

But When I call these services, this throw error

    "errorCode": "METHOD_NOT_ALLOWED",
    "message": "HTTP Method 'GET' not allowed. Allowed are POST"

If I make the method @HttpGet, it works

Have anyone any Idea why @HttpPost is not working?

enter image description here


  • If you want to support both GET and POST, you need to write two separate methods annotated as such... – Adrian Larson Jan 6 '16 at 17:28
  • I Just want to support POST – ashishcloud Jan 6 '16 at 17:30
  • It sounds like when you are testing you are going a GET not a POST. – Keith C Jan 6 '16 at 17:33
  • @KeithC I am doing a post request and getting the error response – ashishcloud Jan 6 '16 at 17:36
  • picpaste.com/Capture-yZu4O6II.PNG Above link is the snapshot of request I am making – ashishcloud Jan 6 '16 at 17:40

I found the problem as I make my site secure by HTTPS and was doing a request on HTTP, So the post request was discarded.


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.