You need to sign in to do that
Don't have an account?
Re: Get POST data via visualforce page
>>All,
>>
>>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.
>>
>>
>>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.
>>
>>-Tom
Nevermind,
I was able to get the POST values using the same technique for GET fields by using.
ApexPages.CurrentPage().getParameters()
ApexPages.CurrentPage().getParameters()
only caveat is you must post to the true url in my case:
c.cs2.visual.force.com/apex/mypage
c.cs2.visual.force.com/apex/mypage
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).
-Tom
well here is the working code:
Code:
<apex:page> <h1>Wrapper to Punchout Site</h1> <br></br><b>Browser Post URL:</b> {!$Page.testProxy} <br></br> <apex:iframe src="http://127.0.0.1/fakePunchout/submitPOOM.html" id="Iframe_Punchout"/> </apex:page> ---------------------------------------------------------------- submitPOOM.html ---------------------------------------------------------------- <html> <body> <h1>DEMO Punchout FORM POST</h1> <form action="https://c.cs2.visual.force.com/apex/testProxy" method="POST" target="_top"> <br/><input type="text" name="cxml-urlencoded" id="payload2" value="POST Entire URL-Encoded PunchOutOrderMessage"/> <input type="submit" value="confirm"/> </form> <br/><br/> <h1>DEMO Punchout FORM GET</h1> <form action="https://cs2.salesforce.com/apex/testProxy" method="GET" target="_top"> <br/><input type="text" name="cxml-urlencoded" id="payload3" value="GET Entire URL-Encoded PunchOutOrderMessage"/> <input type="submit" value="confirm"/> </form> </body> </html> ---------------------------------------------------------------- testProxy ---------------------------------------------------------------- <apex:page controller="testProxy" action="{!init}"> <form> <h1>SFDC - DEMO PROCESS POOM</h1> <br></br> <textarea name="payload" style="width:500px;height=400px;">{!cxml}</textarea> <br></br> {!headers} <br></br> </form> </apex:page> ---------------------------------------------------------------- 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'); headers=''; 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
(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.
Bernardo
Bernardo,
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,
Tom
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.
-Naren
how u processed the post data in vf?can u post the sample code
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
https://developer.salesforce.com/forums?id=906F0000000958DIAQ
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.
riffindus
If you use restresource in apex class,then you can send immediate response msg like this
RestContext.response.responseBody = Blob.valueof('Success');
Here's a sample cURL post to one of the Salesforce account:
curl -v https://agapism-developer-edition.na10.force.com/LeadCaptureParser -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.
Steve