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
Admin XtiAdmin Xti 

500 status code return from request to https://na.salesforce.com/..

500 status code return from request to 
In Production have some reports what I want is a report to run every month and save it inside a custom folder.
In Open Execute Anonymous Window, I run the following code:
 
    ApexPages.PageReference report = null;
    report = new ApexPages.PageReference('/idProductionReport?excel=printable+view');
    Document document = new Document();
    document.Name = 'ReportTest.xls';
    document.AuthorId = UserInfo.getUserId();
    document.FolderId = idFolderProduction;
    document.body = report.getContent();
    document.ContentType = 'application/vnd.ms-excel';
    insert document;
        
In the line 7 is where it shows EXCEPTION_THROWN [7]|System.VisualforceException: 500 status code return from request to https://naXX.salesforce.com/idProductionReport?excel=printable+view&inline=1

The same code work in Sandbox, but not in production

Thanks
saikat sarkarsaikat sarkar
Check The URL/Endpoint as it will vary of Sandbox and Production.
Strand AdministratorStrand Administrator

I am also getting such error but happens very randomly:

First error: [UNKNOWN_EXCEPTION] 500 status code return from request to https://na56.salesforce.com/apex/fafirstpageprint?fa=a0B0Z00000rQDhKUAW&inline=1

Apex Method: Send Email **