You need to sign in to do that
Don't have an account?
yuvrajindia
CalloutException when Post HTTPRequest
String strXML ='<?xml version="1.0" encoding="utf-8"?><clickAPI><sendMsg><api_id>3253451</api_id><user>Medlert</user><password>Password</password><to>919826471817</to><text>SMS Message</text></sendMsg></clickAPI>'; String strUrl = 'http://api.clickatell.com/xml/xml'; HttpRequest req = new HttpRequest(); req.setBody(strXML); req.setMethod('POST'); req.setEndpoint(strUrl); req.setHeader('Content-Type', 'text/xml'); req.setHeader('X-If-No-Redirect', '1' ); Http http = new Http(); HTTPResponse res = http.send(req);
I am useing this code but this is throw exeption:
System.CalloutException: Callout from triggers are currently not supported
Also use this code from globel class with webservice but then how can i call that class.
What is currect way to run this code.
As the exception says - we don't support making HTTP callouts in triggers. You could put this callout in an Apex future request and invoke that future request from the callout.
All Answers
As the exception says - we don't support making HTTP callouts in triggers. You could put this callout in an Apex future request and invoke that future request from the callout.
Thanks for Reply i just added @future and it's now woking.
Thanks to reply
yes i use here @future and now it 's submitted but still xml post is not working... :(
Any one help me please.
What's the error message?
No Error message :(
How is it not working ?
xml is not posting ...when i post this xml from url it send me sms but when i post it from http request it's not send me sms.
The respose to the POST probably contains some useful info that you need to look at.
Also, since you make your callout asynchronously, you're not going to get inline errors. You're probably going to have to add debug statements and then look at the debug logs.