I'm developing a custom apex REST API and running into an issue annotating my getAppDefaults method with @HttpGet. When I remove the annotation and run a test class against the getAppDefaults method, I get my Map of Maps back. But I'd like this returned as a JSON structure from the GET request.
Also, if I change the method to return a String and JSON.serialize(appDefaults), I get a stringified result back from the REST requested (ie, the annotation works fine but I would like to return a JSON structure, not a string).
@RestResource(urlMapping='/v1.0/AppDefaults/*')
global with sharing class hbAppUserDefaults {
... //other internal methods
@HttpGet
global static Map<String, Map<String,Object>> getAppDefaults() {
Map<String, Map<String,Object>> appDefaults = new Map<String, Map<String,Object>>();
Map<String, String> u = new Map<String, String>(getUserDefaults());
Map<String, Object> cases = new Map<String, Object>(getCases());
Map<String, Object> dashboards = new Map<String, Object>(getDashboards());
Map<String, Object> robots = new Map<String, Object>(getRobots());
appDefaults.put('User', u);
appDefaults.put('Cases', cases);
appDefaults.put('Dashboards', dashboards);
appDefaults.put('Robots', robots);
return appDefaults;
}
}
The compile error I get with the code above is as follows:
Any help is greatly appreciated!