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

Retrieving a VisualForce page from an external script


I would like to be able to rerieve a VisualForce page with an http(s) request from within a script running on my server (not having been invoked within a Salesforce session). This, however, requires that the script is 'logged in' - ie. this is not the same as logging in through the web services API. How would this be done? What login sequence, cookies, etc. are needed by the script to enable this?

Colin Goldberg

Ron HessRon Hess
A simple way to get this is to build an Apex Code class that generates the visualforce page, this is easy using new pageReference(...) and getContent(), very powerful, return that string from your class.

Then your class is made into a webservice, which when called will return the string content of the page.

Now your script can simply use the Apex Webservice API to login() and query that webservice class, unpacking the desired contents of the VF page.

This avoids the considerable effort of simulating a browser in script.

Thanks for this - it sounds like the best way to go.

Colin Goldberg