You need to sign in to do that
Don't have an account?
sailer
REST API Intergartion with the other server(By using the Endpoint)
Hello Everyone,
I have given the Endpoint whenever the records are inserted in salesforce.com,i need to get the values from end point in JSON format
and by using External id i need to get that json values and update in salesforce.com
I wrote the trigger to insitate the webservice class
trigger AccountCallout on Account (after insert)
{
for (Account a : Trigger.new) {
// make the asynchronous web service callout
WebServiceCallout.sendNotification(a.Name);
}
}
and this webservice class is
public class WebServiceCallout {
@future (callout=true)
public static void sendNotification(String folionum) {
folionum='484307021840';
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setHeader('content-type', 'application/json; charset=utf-8');
req.setEndpoint('http://abc.cloud.net/api/values');
req.setMethod('POST');
req.setTimeout(60000);
req.setBody('folionum='+EncodingUtil.urlEncode(folionum, 'UTF-8'));
String jsonData = res.getBody();
req.setCompressed(true); // otherwise we hit a limit of 32000
System.debug(res.toString());
System.debug('STATUS:'+res.getStatus());
System.debug('STATUS_CODE:'+res.getStatusCode());
try
{
res = http.send(req);
}catch(System.CalloutException e)
{
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
}
when i check teh logs i get the error has
System.HttpRequest[Endpoint=http://abc.cloud.net/api/values, Method=POST]
20:24:21.928 (4928855000)|CALLOUT_RESPONSE|[22]|System.HttpResponse[Status=Internal Server Error, StatusCode=500]
I have given the Endpoint whenever the records are inserted in salesforce.com,i need to get the values from end point in JSON format
and by using External id i need to get that json values and update in salesforce.com
I wrote the trigger to insitate the webservice class
trigger AccountCallout on Account (after insert)
{
for (Account a : Trigger.new) {
// make the asynchronous web service callout
WebServiceCallout.sendNotification(a.Name);
}
}
and this webservice class is
public class WebServiceCallout {
@future (callout=true)
public static void sendNotification(String folionum) {
folionum='484307021840';
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setHeader('content-type', 'application/json; charset=utf-8');
req.setEndpoint('http://abc.cloud.net/api/values');
req.setMethod('POST');
req.setTimeout(60000);
req.setBody('folionum='+EncodingUtil.urlEncode(folionum, 'UTF-8'));
String jsonData = res.getBody();
req.setCompressed(true); // otherwise we hit a limit of 32000
System.debug(res.toString());
System.debug('STATUS:'+res.getStatus());
System.debug('STATUS_CODE:'+res.getStatusCode());
try
{
res = http.send(req);
}catch(System.CalloutException e)
{
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
}
when i check teh logs i get the error has
System.HttpRequest[Endpoint=http://abc.cloud.net/api/values, Method=POST]
20:24:21.928 (4928855000)|CALLOUT_RESPONSE|[22]|System.HttpResponse[Status=Internal Server Error, StatusCode=500]
If there is then you may have to contact Salesforce with the Error number so they may be able to find out the exact reason.
Regards,
Satish Kumar