1

I have created a method to update the records in a case.

@RestResource(urlMapping= '/FieldCases/*')
global with sharing class RestCaseController {
    @HttpPatch
    global static String caseUpdate(String caseId, String caseStatus, String caseNote){
        Case companyCase = [SELECT Id, Subject, Status, Description FROM Case WHERE Id = :caseId];

        companyCase.Status = caseStatus;
        companyCase.Description += caseNote;
        update companyCase;

        Return 'Updated';
    }
}

and in work bench I am using

/services/apexrest/FieldCases

{"caseId" : "0037F00000bQYIjQAO",
 "caseStatus" : "Working",
 "caseNote" : "updating from the work bench"} 

but I am getting the below error

HTTP Method 'PATCH' not allowed. Allowed are POST,DELETE,GET,HEAD

  • I think you need to pass CaseID also in URL. Like this : /services/apexrest/FieldCases/0037F00000bQYIjQAO – Mr.Frodo Jun 2 '18 at 7:58
  • Thank you so much for responding but the error is still the same :( – gs650x Jun 2 '18 at 8:02
  • @gs650x looks like issue with workbench. Can you try it in postman? – Pranay Jaiswal Jun 2 '18 at 11:44
2

Hey I tried it myself with workbench and it seems to be working for me, I am posting screenshots here:

Apex class

Workbench result

API Version could be the issue in your case, Try changing your Apex class to latest api version.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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