# REST API - Generate Report

**URL:** <https://www.epiusers.help/t/rest-api-generate-report/70247>\
**Category:** Epicor ERP 10\
**Tags:** e10, epicor\
**Created:** [August 24, 2020, 2:09pm UTC](https://www.epiusers.help/t/rest-api-generate-report/70247 "2020-08-24T14:09:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tanner](https://www.epiusers.help/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tanner](https://www.epiusers.help/u/tanner)\
**Post date:** [August 24, 2020, 2:39pm UTC](https://www.epiusers.help/t/rest-api-generate-report/70247/2 "2020-08-24T14:39:21Z")

</div>

Yes you can do this. Running the report is fairly straightforward by calling RunDirect method on ARInvoiceSvc. The tricky thing is locating the rendered report and then decoding the file. I wrote a BAQ to get the report (looking for unique values from TaskNote and TaskDescription but you may want something more robust).

**BAQ Retrieval Example:**

```auto
select top (1)  
	[SysTask].[SysTaskNum] as [SysTask_SysTaskNum],
	[SysRptLst].[RptData] as [SysRptLst_RptData]
from Ice.SysTask as SysTask
inner join Ice.SysRptLst as SysRptLst on 
	SysTask.Company = SysRptLst.Company
	and SysTask.SysTaskNum = SysRptLst.SysTaskNum
where (SysTask.Company = @CurrentCompany and SysTask.TaskDescription = @inTaskDesc and SysTask.TaskNote = @inTaskNote)
order by SysTask.SysTaskNum Desc

```

**PDF Retrieval Example:**

```auto
var myinvfname = string.Format("ARInvForm_{0}.pdf", InvoiceNumber);

byte[] dataBytes = System.Convert.FromBase64String(myobj.SysRptLst_RptData);
result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(dataBytes);
result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("inline");
result.Content.Headers.ContentDisposition.FileName = myinvfname;
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return result;
```

---

_[View the full topic](https://www.epiusers.help/t/rest-api-generate-report/70247)._
