0

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?

2

2 Answers 2

0

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();
  }
}
1
  • Note: sometimes there are some differences when accessing the parameters of the get request - I think this is the right way, but I haven't tested. Jan 26, 2021 at 7:13
-1

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.

You must log in to answer this question.

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