getContentAsPDF() is returning Internal Salesforce.com Error when called from a webservice. I have a webservice defined which essentially creates a BLOB from a visualforce page generated as a pdf and then returns the same as response payload.
I am getting this response back in the webservice : "401 status code return from request to https://xxx.salesforce.com/apex/clientagreement?ids=xxxxxxxxxxxxxx&inline=1",
In my debug I get a Internal Salesforce.com Error on the same line as the method getContentAsPDF is being called.
However, when I run the exact code from Developer console anonymous window providing the exact same parameters, the code is executing correctly.
Has anyone faced a similar issue?