I have created an rest api in salesforce and can be accessed using site.com with the class url, while accessing the rest api in browser I am getting response as
<response>
[{"attributes":{"type":"Account","url":"/services/data/v37.0/sobjects/Account/0012800000hij6DAA Q"},"Name":"GenePoint","Id":"0012800000hij6DAAQ"},{"attributes":{"type":"Account","url":"/services/data/v37.0/sobjects/Account/0012800000hij6BAAQ"},"Name":"United Oil & Gas, UK","Id":"0012800000hij6BAAQ"},{"attributes":{"type":"Account","url":"/services/data/v37.0/sobjects/Account/0012800000hij6CAAQ"},"Name":"United Oil & Gas, Singapore","Id":"0012800000hij6CAAQ"},{"attributes":{"type":"Account","url":"/services/data/v37.0/sobjects/Account/0012800000hij63AAA"},"Name":"Edge Communications","Id":"0012800000hij63AAA"},{"attributes":{"type":"Account","url":"/services/data/v37.0/sobjects/Account/0012800000hij64AAA"},"Name":"Burlington Textiles Corp of America","Id":"0012800000hij64AAA"}]
</response>
The information json is in tag. How to avoid the
My Code :
@RestResource(urlMapping='/mycall/*')
global class mycallclass{
@HttpGet
global static String getmycall() {
Map<String, String> params = RestContext.request.params;
String name = params.get('name');
System.debug('param value :: '+name);
List<Account> acc = [Select name From Account Limit 5];
System.debug('Accoount test ' + JSON.serialize(acc));
return JSON.serialize(acc);
}
}
Can anyone please help me to fix this issue.