You need to sign in to do that
Don't have an account?
divya1234
Poat method sending request twice while updatinng a record
Hi All,
I created post method in my controller class but i can see that post method is send request twice to the middlewre while updating record,but while creating a record it is sending request only onece ,hereis my sample post class ,can someone please suggest me how i can improve my method.
I created post method in my controller class but i can see that post method is send request twice to the middlewre while updating record,but while creating a record it is sending request only onece ,hereis my sample post class ,can someone please suggest me how i can improve my method.
public static HttpResponse postData(String url, String json) { HttpResponse response; HttpRequest req = new HttpRequest(); req.setClientCertificateName('HttpClientCert'); req.setMethod('POST'); req.setEndpoint(url); req.setHeader('Content-Type', 'text/plain; charset=utf-8'); req.setTimeout(30000); //req.setHeader('Content-Type', 'application/json; charset=utf-8'); req.setHeader('SOAPAction', url); req.setBody(json); Http httpSender = new Http(); String responseString = ''; try { if (!Test.isRunningTest()){ response = httpSender.send(req); }else{ response = new HttpResponse(); } } catch(System.CalloutException e) { system.debug('***********'+e); } return response; }
i do not see any problem in the above code.