1

I have an apex method with return type PageReference. When the method returns value a custom visualforce page is loaded. I want to pass few parameters from the method to the visualforce page. At the moment I'm using the following method:

pageRef.getParameters().put('accIds', allAccIds);

The problem here is that when the visualforce page is loaded in the browser then all parameters are included in the URL as GET parameters.

Is there a way in Salesforce to pass them as POST parameters so they are not displayed and visible in the URL address?

  • Did you try using setRedirect as false in pagereference? – Raul Mar 15 '17 at 20:34
0

You can leverage Http POST method to send data.

String body = 'accIds' + allAccIds;
HttpRequest req = new HttpRequest();
req.setEndpoint('***https://my_endpoint.example.com/some_path***');
req.setMethod('POST');
req.setbody(body);
Http http = new Http();
HTTPResponse response = http.send(req);
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.