API way to get PDF of Job Travler

I was wondering if there is a way of printing the job traveler or generating the job traveler from the api. I need to automate the process.

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

I am doing this from Java so I am trying to translate the above. So the Erp.RPT.JobTravSvc generates the Job Traveler Report? and what does Production-DownloadTravRpt do ? and how do I create that? You mention a library.

yes, thanks to @josecgomez and @jgiese.wci there are helper libraries. I don’t think they is one for java though

We don’t have one for Java… we could write one… maybe… UGH haha

Say @Andrew_Burger how about shifting to C#? LoL

1 Like

@josecgomez Sorry I am diehard Java Developer.
I have Java code already calling the some of the endpoints of the REST api already. I am new to EPICOR development so I am learning the endpoints names and the required parameters. So Erp.RPT.JobTravSvc and Production-DownloadTravRpt endpoints and trying to figure out how to reproduce the required parameters to get the JobTraveler to download or print. From what I am learning is there is a way to get it to print from a REST endpoint as well as getting it to download. My assigned task is to get the JobTraveler to print with all the attachments in a client app that I have written in Java. So any help understanding how to print or download or both would be helpful.

That Production Download RPT is a BAQ (Epicor Query) that @Evan_Purdy wrote which takes the bytes of the report and returns them as a byte array.
He can maybe provide a copy of the BAQ, without it, its pretty hard to get the data from the Report.

The parameters sent to the JobTravSvc are required as @Evan_Purdy sent you can’t send less. Not Unless you write an Epicor function (what version of Epicor are you on) which can do it all in a single call.

1 Like

Its a super simple BAQ:
Production-DownloadTravRpt.baq (13.4 KB)

1 Like

Thanks so much. :slight_smile:

This is a stupid question but is there a way to tell what version the customer is running from the rest api?

How do I use this?

Evan shows you how here…