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
thorsten_dthorsten_d 

@RestResource context switches to guest license when calling PageReference

Hi,

 

I've a RestResouce class with a bunch of methods.

A thrid party Java App is calling that class using a systemadmin profile user.

That's all fine for every method I've written.

 

Now I've one method that is using a PageReference to create a pdf.

When i take a look at the debug logs, the call to the page itself is done using the guest license, not the authorized user that is calling the rest service. 

 

The log overview looks like:

 

myInterface SiteGuestuser       Application      Browser      /apex/myDocument

ServiceAgent                              Api                     Unknwon   /makeDocument

 

private static void makeDokument(RestRequest req, RestResponse res) {
   ...
   String uri = '/apex/' + pdfName + params;
   PageReference pdf = new PageReference(url);
        
   res.responseBody = pdf.getContent();
}

 

What is the missing piece to call the PageReference using the ServiceAgent user?

 

Thanks in advance.

Thorsten