+ Start a Discussion
salesforcequestions123salesforcequestions123 

How read a http post from site url

Hi ALL

 

I am getting a http post containing json data to my site url .I need to get the json data into my controller so I can parse it.How can I do that

digamber.prasaddigamber.prasad

Hi,

 

I assume you are geeting JSON data  on your site URL in querystring parameter. Which may look like something:-

 

https://<domain of your site>/apex/<pageName>?JSONBody=<jsonData>

 

If yes, then you can use  below to get value of query string parameter, which will contain post data.

 

ApexPages.currentPage().getParameters().get(<Query String parameter name>)

 Once you get the body of post data, you can use APEX JSON and parse data and proceed accordingly. For help on APEX JSON, you can see following URL:-

 

http://wiki.developerforce.com/page/Getting_Started_with_Apex_JSON

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_json_overview.htm

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_json_jsonparser.htm

 

Hope it will help you.

 

Happy to help you!

 

Regards,

Digamber Prasad