• wei j
  • 0 Points
  • Member since 2014

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 0
Hi All,

What I need to implement:
A VF page includes a command button "Date Entry", once users click the button, a few pramas need to be past (use POST rather than GET) to external data entry website, the page also need to be redirected to external data entry website.

I googled many related solutions, they all use GET which is appended all parameters in URL, such as:
public PageReference redirect2DataEntry(){
        PageReference pageRef = new PageReference('https://www.dataentry.com/login');
        pageRef.getParameters().put('username', 'abc');
        pageRef.getParameters().put('passcode', 'xyz');
        .... ....
        return pageRef;

My question is, can we use POST (append params in HTTP header) to pass the parameters? Some one mentioned that HttpRequest class can be used to send POST request (see below), but the problem is how can I redirect to external web page at the same time by using HttpRequest class in the controller?


String endpoint = 'http://www.example.com/service'; 
String body = 'fname=firstname&lname=lastname&age=34'; 
HttpRequest req = new HttpRequest(); 
Http http = new Http(); 
HTTPResponse response = http.send(req);

Thanks in advance.
  • March 22, 2015
  • Like
  • 0