You need to sign in to do that
Don't have an account?
Sabarinathan N
Force.com site
Hi All,
Im creating force.com site. When i hit the endpoint url for accessing Case in apex class. It is giving xml response. But I need the response in JSON format.
@RestResource(urlMapping='/Cases/*')
global with sharing class CaseManager {
@HttpGet
global static List<case> getCaseById() {
RestRequest request = RestContext.request;
RestResponse response = RestContext.response;
HttpRequest request1 = new HttpRequest();
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
List<Case> result = [SELECT CaseNumber,Subject,Status,Origin,Priority FROM Case limit 1];
return result;
}
Thanks in Advance
Im creating force.com site. When i hit the endpoint url for accessing Case in apex class. It is giving xml response. But I need the response in JSON format.
@RestResource(urlMapping='/Cases/*')
global with sharing class CaseManager {
@HttpGet
global static List<case> getCaseById() {
RestRequest request = RestContext.request;
RestResponse response = RestContext.response;
HttpRequest request1 = new HttpRequest();
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
List<Case> result = [SELECT CaseNumber,Subject,Status,Origin,Priority FROM Case limit 1];
return result;
}
Thanks in Advance
Try below code to convert response into JSON.
Let me know if this works. Thanks,
Thank you so much!!! for your response ravi. It return json but inside of xml tag. See the attachment..