below is my code Created a wrapper class like below
public class ResponseWrapper{
public list<Account> lstaccounts;
public boolean isError ;
public string errorCode;
public integer statusCode;
public ResponseWrapper(){
lstaccounts = new list<Account>();
isError= false;
}
}
and returning the wrapper class in the Httpget method
@RestResource(urlMapping='/accounts/*')
global with sharing class AccountRestService {
@HttpGet
global static ResponseWrapper getAccounts() {
ResponseWrapper resWrap = new ResponseWrapper();
List<Account> accounts;
try {
accounts = [SELECT Id, Name FROM Account];
res.lstaccounts = accounts;
} catch (Exception e) {
RestResponse res = RestContext.response;
resWrap.isError = true;
res.responseBody = Blob.valueOf(e.getMessage()) = resWrap.errorCode;
res.statusCode = 500 = resWrap.statusCode;
}
return resWrap;
}
}
but its throwing the Error message Error: Compile Error: global methods do not support return type of ResponseWrapper at line 4 column 31