Expanding on Mohith's answer, you may only define a single @HttpGet
annotated method on your class, but, according to the docs,
Methods annotated with @HttpGet or @HttpDelete should have no
parameters. This is because GET and DELETE requests have no request
body, so there's nothing to deserialize.
So you should have a single REST method that examines query parameters and responds accordingly:
@RestResource(urlMapping='/RestResearch/v1/Test')
global with sharing class RestResearch {
@HttpGet
global static Account doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
// Was the method called like http://na1.salesforce.com/services/apexrest/RestResearch/v1/Test?s2=something
String s2 = req.params.get('s2');
if (s2 != null) {
// Process s2 version
} else {
// Do something else
}
return result;
}
}
Similarly, for a @HttpPost
method, you would deserialize the body and examine it:
@HttpPost
global static String doPost(){
RestRequest req = RestContext.request;
RestResponse res = Restcontext.response;
Blob body = req.requestBody;
Map<String, Object> m = (Map<String, Object>)JSON.deserializeUntyped(body.toString());
if (m.get('s2')) {
// Process s2 version
} else {
// Do something else
}
return result;
}
If you are trying to load the data synchronously, then it will hit this limit of 6MB. I'd recommend you call asynchronously, which is nothing but using VisualForce Remoting functions.
Can you paste your code so that I'll point out a better way to go about it.
Thanks
Akash
Best Answer
If you want information from both the Objects you can make a wrapper Object of Account and Contact and this Wrapper you can also use on visualforce Page .
For making callout use HTTP methods .The REST annotations are used to make a custom REST API .
http://cloudyworlds.blogspot.in/2012/11/native-parsing-of-json-input-into-user.html
Here is blog link i blogged if external system inputs JSON in userdefined format .You can even construct wrapper response type JSON if you are exposing multiple object data at a time
Here is the link of the blog of how wrapper data is formed
http://cloudyworlds.blogspot.in/2012/09/how-to-generate-wrapped-data-from.html