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
Aphinya PhansawangAphinya Phansawang 

How to get POST request raw body in Visualforce Page

Hi All,

I'm developing webhook integration with Salesfroce using site.com work around.
I redirect webhook requst url to salesforce site and use controller to get POST parameters.

I use command below to get POST parameters.
MAP<string, string> params = ApexPages.currentPage().getParameters();
for (string paramname : params.keySet() )
 body += paramname + '=' + params.get(paramname) + '\n';
if (body.endsWith('=\n')) {
 body = body.substring(0,body.length()-2);
}
The command above working find for normal string value but I have problem when try to get data of pdf file that send as binary data.
I can get only file name and file type, cannot get file content.

Below is results of the code above.
nullAppID=123
AppReference=JaneDoe
file=/var/www/examples/post/123.pdf
file.org.eclipse.jetty.servlet.contentType=application/octet-stream

Have any one have a work around to get the raw body of POST request or get the file content that send via POST request.


Thank you,

Aphinya