Printing from a uBAQ called via REST fails

You probably don’t use those in REST. I assume in REST you would have a Service Account for API Calls, with Session Impersonation.

First of all Recommendation from @aidacra

Basically what that setting does is when you Submit a Queued Job to the Agent, it knows where to send the ex PDF Preview too. Imagine if you have a Terminal Server (Citrix, RDS) you probably have 30-50 Users Connected, it determines where to send the result to. Have you ever been connected to 2-3 PCs with the same UserID and you Print Preview something, it doesn’t show up, later you login and they all popup.

You can Run Reports Directly (example one)

api/help/v1/methods/Erp.RPT.GlBookReportSvc/index#!/Custom_methods/RunDirect

Then there is a GetReportBytes API Call you can get the bytes and write to ex .pdf

The Equivalent in LINQ (perhaps its easier to understand) is:

var SysRptRow =
(from sr in Db.SysRptLst.With(LockHint.NoLock)
  where
    sr.Company == Session.CompanyID
    && sr.UserID == Session.UserID
    && sr.RptDescription.Contains("Process Payments")
    && sr.PrintProgram.Contains("MICRChkPrint")
    && sr.RptData != null
  orderby sr.SysTaskNum descending
  select sr
).FirstOrDefault();


if (SysRptRow != null) {
  System.IO.File.WriteAllBytes(@"\\UNC\Path\file.pdf", SysRptRow.RptData);
}
1 Like