• dai tran 12
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
This my webservice:
@RestResource(urlMapping='/Cases/*')
global with sharing class CaseManager {
global static Map<String,List<Case>> getCaseById() {
        RestRequest request = RestContext.request;       
        String caseId = request.requestURI.substring(
          request.requestURI.lastIndexOf('/')+1);
        List<Case> result;   
          result =  [SELECT CaseNumber,Subject,Status,Origin,Priority
                        FROM Case Where Id=:caseId];     
        Map<String,List<Case>> res=new Map<String,List<Case>>();
        res.put('Cases', result);
        return res;
    }
 @HttpPost
    global static ID createCase(String subject, String status,
        String origin, String priority) {
        Case thisCase = new Case(
            Subject=subject,
            Status=status,
            Origin=origin,
            Priority=priority);
        insert thisCase;
        return thisCase.Id;
    }   
 @HttpPost
  global static Map<String,List<Case>> getDataGroupOfUser(String userid, String group)
   {     
       List<Case> result;   
          result =  [SELECT CaseNumber,Subject,Status,Origin,Priority
                        FROM Case Where userId__c=:userid and group__c=:group];     
        Map<String,List<Case>> res=new Map<String,List<Case>>();
        res.put('Cases', result);
        return res;
    }   
}

Error: Only one method per type can be defined with: HttpPost
How can define multi function get or post in a class of webservice?
This my webservice:
@RestResource(urlMapping='/Cases/*')
global with sharing class CaseManager {
global static Map<String,List<Case>> getCaseById() {
        RestRequest request = RestContext.request;       
        String caseId = request.requestURI.substring(
          request.requestURI.lastIndexOf('/')+1);
        List<Case> result;   
          result =  [SELECT CaseNumber,Subject,Status,Origin,Priority
                        FROM Case Where Id=:caseId];     
        Map<String,List<Case>> res=new Map<String,List<Case>>();
        res.put('Cases', result);
        return res;
    }
 @HttpPost
    global static ID createCase(String subject, String status,
        String origin, String priority) {
        Case thisCase = new Case(
            Subject=subject,
            Status=status,
            Origin=origin,
            Priority=priority);
        insert thisCase;
        return thisCase.Id;
    }   
 @HttpPost
  global static Map<String,List<Case>> getDataGroupOfUser(String userid, String group)
   {     
       List<Case> result;   
          result =  [SELECT CaseNumber,Subject,Status,Origin,Priority
                        FROM Case Where userId__c=:userid and group__c=:group];     
        Map<String,List<Case>> res=new Map<String,List<Case>>();
        res.put('Cases', result);
        return res;
    }   
}

Error: Only one method per type can be defined with: HttpPost
How can define multi function get or post in a class of webservice?