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?

3 Answers 3


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.

Can I have a public APEX REST API?

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:

  1. Contact the Salesforce administrator to do the first suggestion;
  2. See if there're any XHR calls to populate the content of the page - you could then query that;
  3. 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.

If you know JavaScript and are familiar with Node.js, there are great libraries to simplify scraping, such as cheeriojs (https://github.com/cheeriojs/cheerio). I know you can find some interesting ones too in Ruby, Golang or Python.

Good luck!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .