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;
}
}
@getMethod
@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 iam getting the below Error: Compile Error: global methods do not support return type of ResponseWrapper at line 4 column 31
Please check and suggest on this whats the exact mistake i did.
Thanks & Regards. Vamsi Krishna.