API way to get PDF of Job Travler

Yes, you can do this with the REST api & helper library on this forum. An excerpt from one of my programs as reference:

        private static bool TryDownloadingJobSSRS(string jobNum, int numCopies, string reportStyleID, string printerName, string suffix)
        {
            var reportGUID = Guid.NewGuid().ToString();
            var pData = new
            {
                ds = new
                {
                    JobTravParam = new[]
                    {
                        new
                        {
                            PrntAllMassPrnt = false,
                            Jobs = jobNum,
                            Assembly = "0",
                            ReportStyleNum = reportStyleID,
                            AutoAction = "SSRSPREVIEW",
                            SSRSRenderFormat = "PDF",
                            TaskNote = reportGUID,
                            ShpSchd = true,
                            BarCodes = true,
                        },
                    },
                },
            };
            var pdfFileName = $@"{Settings.Default.TempPDFLocation}{jobNum}{suffix}.pdf";
            EpicorRest.DynamicPost("Erp.RPT.JobTravSvc", "RunDirect", pData);
            if (EpicorRest.LastCallResult != System.Net.HttpStatusCode.OK)
            {
                Log.Error($"[{jobNum}] FAILED TO GENERATE REPORT. See error:");
                Log.Error(EpicorRest.LastCallErrorMessage);
                critialErrors += 1;
                return false;
            }

            var reports = EpicorRest.DynamicGet("BaqSvc", "Production-DownloadTravRpt", new Dictionary<string, string>() { { "GUID", reportGUID } });
            if (EpicorRest.LastCallResult != System.Net.HttpStatusCode.OK)
            {
                Log.Error($"[{jobNum}] FAILED TO DOWNLOAD REPORT. See error:");
                Log.Error(EpicorRest.LastCallErrorMessage);
                critialErrors += 1;
                return false;
            }
            else if (reports["value"].Count <= 0)
            {
                Log.Error($"[{jobNum}] ERROR: BAQ 'Production-DownloadTravRpt' returned no results, so no report could be downloaded.");
                critialErrors += 1;
                return false;
            }

            try
            {
                File.WriteAllBytes(pdfFileName, Convert.FromBase64String(reports["value"].Last.SysRptLst_RptData.ToString()));
                return true;
            }
            catch (Exception e)
            {
                Log.Error($"[{jobNum}]: Could not save report pdf. File path: {pdfFileName}");
                Log.Error($"[{jobNum}]: Error: {e}");
                critialErrors += 1;
                return false;
            }
        }
6 Likes