We have API access via REST and need to grab the contents of a rendered page located at https://xyz.visual.force.com/apex/page?id=x
Is there any API or way to render this remotely?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityWe have API access via REST and need to grab the contents of a rendered page located at https://xyz.visual.force.com/apex/page?id=x
Is there any API or way to render this remotely?
If you are able to create a Rest class, you could create a very small class to render the page and return it to you as a string.
Something like:
@RestResource(urlMapping='/PageContent/*')
global with sharing class PageContentService {
@HttpGet
global static String getPageContent(){
String pageId = RestContext.request.params.get('id');
Blob pageContent;
PageReference pageref = Page.YourPage;
pageRef.getParameters().put('id',x);
pageContent = pageref.getContentAsPDF);
return pageContent.toString();
}
}
So it turns out, you can access the page via an API bearer token.
Just pass it via Authorization
header and you can get the page! I didn't see any documentation on this however.