+ Start a Discussion

GET response on Submitting HTML Form from Visualforce



I am Using a Visualforce Page with HTML Form which POST s Data to a URL.


When i Click Submit (HTML) Button the form action is calling a External URL(which i am sending Data) , and on that Page some response is Displayed.


Can we get that response back to Visualforce or Pass to Controller so that I can save that back in Salesforce.


Please suggest any solution.


Thanks in advance.


My Form Code:


<form name="form1" method="post" action= "https://www1.abc.com/partners/abcd/" target="blank">
<input type="submit" name="Submit" value="Initiate"/>
<input type="hidden" name="ExpressXML" value="{!XML}"/>





Mohith Kumar ShrivastavaMohith Kumar Shrivastava

Why dont you prefer using HTTP Request methods on button click instead of using html?



public class AuthCallout {
   public void basicAuthCallout(){
     HttpRequest req = new HttpRequest();
     // Specify the required user name and password to access the endpoint 
     // As well as the header and header information 
     String username = 'myname';
     String password = 'mypwd';
     Blob headerValue = Blob.valueOf(username + ':' + password);
     String authorizationHeader = 'BASIC ' +
     req.setHeader('Authorization', authorizationHeader);
     // Create a new http object to send the request object 
     // A response object is generated as a result of the request   
     Http http = new Http();
     HTTPResponse res = http.send(req);





Thanks for the Reply,


This Approach i used but in this approach i am un able to pass XML to the SERVER, its giving response as XML content Missing.

I tried different ways like sending XML as Setbody, setbodydocument , even set header etc.. but i am un able to send the XML to their server.


so i am trying if i can read the response using the HTML form.