I need to integrate with client Force.com site and there is something I have problem with.... Is it possible to retrieve data that was used to create this page? I mean one of parameter is parent record Id, child records are displayed in table. When I use REST GET method I get html page as response. Is it possible to retrieve this data(child records) in XML , JSON or some other form just having Force.com Site URL?
The Force.com database is a secure database. If you're asking whether you can query the database using the URL of a page that displays the data you're looking for, the answer would be no. The page that displays that data would be generated using VisualForce on the Server Side and displayed as HTML on the browser side.
If you have control of the force.com site and you're not just trying to scrape someone else's site, you could create an Apex class and use the REST modifiers to create REST actions.
After creating the REST service you can make it public on the Force.com Site by adding it to the public access settings for the Site.
The same can be done for a SOAP API as well if SOAP is better suited to your integration.
Otherwise, no, as crmprogdev mentioned, Force.com Sites is a secure product designed to allow the developer to expose as much as wanted, but not more than that. If the product were open in the way you ask, anyone could just come through and "borrow" your sales leads, accounts, etc.
If you have access to the Salesforce instance outputting this Site
You could create a distinct Visualforce and output as a JSON object the result of that SOQL query processed in that other page. Then, you simply have to expose that Visualforce page to the Site.
If you do not have access to that Salesforce instance and if this system doesn't provide any REST endpoint
I see two options:
- Contact the Salesforce administrator to do the first suggestion;
- See if there're any XHR calls to populate the content of the page - you could then query that;
- If you can't do that with their agreement, the only other option is to build a good old scraper and process the output (of course, this is considered questionable/illegal for many people).
If #3 is your only option, I'd suggest building a middleware in a different language than Apex providing some good libraries to consume that HTML and process it, and then expose it in JSON through your own REST endpoint. Then, call that JSON endpoint from your Apex code.