You need to sign in to do that
Don't have an account?
Ravi kumar 292
How to pass the parameters to the Service endpoint URL
Hi all,
I want to pass the Parameters(Status and Amount) to the service endpoint URL. How can i do this. Please help.
Whenever i click on Custom Button i will redirect to the vf page. and call the class.
Below is my code..
VF page:
<apex:page standardController="Lead" extensions="LDController" action="{!CallBack}" >
</apex:page>
Class:
public with sharing class LDController {
public String LeadId {get;set;}
public LDController(ApexPages.StandardController controller) {
LeadId=ApexPages.currentPage().getParameters().get('id');
system.debug('LeadId '+LeadId);
}
public void getAndParse(String POST) {
String body ='LeadId='+LeadId+'';
system.debug('------'+body);
// Get the XML document from the external server
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://test.com/');
req.setMethod('POST');
req.setbody(body);
HttpResponse res = http.send(req);
String response=res.getBody();
System.debug('Response '+response);
}
public Void CallBack(){
getAndParse('POST');
}
}
Thanks in advance...
I want to pass the Parameters(Status and Amount) to the service endpoint URL. How can i do this. Please help.
Whenever i click on Custom Button i will redirect to the vf page. and call the class.
Below is my code..
VF page:
<apex:page standardController="Lead" extensions="LDController" action="{!CallBack}" >
</apex:page>
Class:
public with sharing class LDController {
public String LeadId {get;set;}
public LDController(ApexPages.StandardController controller) {
LeadId=ApexPages.currentPage().getParameters().get('id');
system.debug('LeadId '+LeadId);
}
public void getAndParse(String POST) {
String body ='LeadId='+LeadId+'';
system.debug('------'+body);
// Get the XML document from the external server
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://test.com/');
req.setMethod('POST');
req.setbody(body);
HttpResponse res = http.send(req);
String response=res.getBody();
System.debug('Response '+response);
}
public Void CallBack(){
getAndParse('POST');
}
}
Thanks in advance...
Refer the below link you get some idea,
https://developer.salesforce.com/forums/?id=906F0000000BC7CIAW
Thanks,
Vijay