function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Re: Get POST data via visualforce page

>>Does anyone know if it is at all possible to get access to to the POST data from a visualforce page when posting from another domain. The >>example below works fine for GET but I actually prefer to use POST if at all possible.
I was able to get the POST values using the same technique for GET fields by using.
only caveat is you must post to the true url in my case:
luckily the $Page.mypage returns the true url.
Sorry about the previous Message,  my sample code seemed to hose the page so I could not reply or remove
(don't use chrome to post messages and paste code).
well here is the working code:
<h1>Wrapper to Punchout Site</h1>
 <br></br><b>Browser Post URL:</b>  {!$Page.testProxy}
 <apex:iframe src="" id="Iframe_Punchout"/>

    <h1>DEMO Punchout FORM POST</h1>
    <form action="" method="POST" target="_top">
  <br/><input type="text" name="cxml-urlencoded" id="payload2" value="POST Entire URL-Encoded PunchOutOrderMessage"/>
        <input type="submit" value="confirm"/>

 <h1>DEMO Punchout FORM GET</h1>
    <form action="" method="GET" target="_top">
     <br/><input type="text" name="cxml-urlencoded" id="payload3" value="GET Entire URL-Encoded PunchOutOrderMessage"/>
        <input type="submit" value="confirm"/>

<apex:page controller="testProxy" action="{!init}">
  <textarea name="payload" style="width:500px;height=400px;">{!cxml}</textarea>
public class testProxy {
    public string cxml{get; set;}
    public string headers {get; set;}

    public PageReference init() {
     if ( ApexPages.currentPage().getParameters().get('cxml-urlencoded') != null )
         cxml = ApexPages.currentPage().getParameters().get('cxml-urlencoded');
        MAP<string, string> hdrs = ApexPages.currentPage().getheaders();
        for (string key : hdrs.keySet() )
            headers += key + ' : ' + hdrs.get(key) + '\n';
        return null;


Message Edited by tesii on 01-06-2009 12:35 PM

Message Edited by tesii on 01-06-2009 12:36 PM
Hi Tom.

(I'm a salesforce partner.)

We have a request that looks pretty much like what you've posted.

We are using Activa Live Chat with salesforce for a customer, and we need to create a case as soon as a chat session ends. This can be done only via sending an XML file from Activa to a VF page using http POST. Once we get the variable, handling the content is quite easy in VF. The problem is that I don't know how to manage the POSTed variables.

I can see you did solve this issue...

Any ideas?

Thank you very much in advance.



I know nothing of Activa Live Chat,  In my case I had the service send the payload via a POST from the client browser such as:

<form id="browserpost" method="POST" action="myVFpage"> <input type="hidden" name="payload-base64" value="Insert base64 xml here"/> </form> <script> function sendform() { getElementById('browserpost').send(); } </script>


In the myVFpage controller you just pull the parameter 'payload-base64' as you would if it was in the querystring via currentpage.getParameters.get('payload-base64');



I used base64 cause it handles the xml encoding.   If the payloads are too large or undermined at time of client completion,  you could just have them pass a token in the above step,  and make a subsequent request to service using HTTPRequest.


Hope this helps,




Message Edited by tesii on 12-15-2009 08:25 AM

Hi Experts,

   I am able to process the POST using Site/Visual Force Page from a sender.

How can i send immediate response to the sender (that POSTed teh original message) that message is successful. Please note that Sender's requirements is NOT to send a new POST back.


Any ideas?


I appreciate your help.




how u processed the post data in vf?can u post the sample code

Pro tip: If you want to be able to grab POST body params make sure you specify the Content-Type header appropriately.  For example if you have key value pairs you will want application/x-www-form-urlencoded

I am not clear with getting parameters when it comes from POST. can you please explain little bit more

for example, if the below link is the URL

and if i want to cpature the id, i use ApexPages.currentPage().getParameters().get('id');

how to write the code if it comes as POST. Please let me know.

Hi narens,

If you use restresource in apex class,then you can send immediate response msg like this
RestContext.response.responseBody = Blob.valueof('Success');

Steve Do 1Steve Do 1
Hi, I am posting XML data to one of the public Salesforce pages for the account so there are no query parameters passed in the post, just the body containing the XML data.  The ApexPages.currentPage().getParameters method obviously will not return any info.  I already tried to access the RestContext.response and RestContext.request objects, but both are null, probably because it was not set up as a REST service.  I tried the ApexPages.currentPage().getContent(), but that seems to be giving me some sort of error.  What method or approach (besides REST) can I use to access the POST body that does not contain any query parameters?  We do not plan to use Salesforce REST service because it requires authentication that the third party application doing the POST may not support.

Here's a sample cURL post to one of the Salesforce account:
curl -v  -H "Content-Type: text/xml" -d @ShortForm_Refinance_NewVersion.xml

I can't seem to find an answer for this.  Thank you for your help.  It's much appreciated.