Skip to main content
Answer

Print SO Invoice via REST API call

  • November 5, 2025
  • 9 replies
  • 88 views

Is there any way to call the PrintInvoice action on an SO Invoice and specify the printer to get a paper copy?  I’ve made an entry in our custom endpoint to call the PrintInvoice action on an invoice, but when I submit the PUT, I’m getting an error “Invalid URI structure”.

I’m supplying this JSON in the body of the call:

{
"entity": {
"DocType":{"value":"Invoice"},
"ReferenceNbr":{"value":"AR006006"}
},
"parameters":null
}

Any ideas on how to accomplish this?

Best answer by aleksejslusar19

@AllenVaughn 
Sorry for the delayed response. I needed time to understand how it works in practice :)
Below are step-by-step instructions.

  1. You need to expand the web service endpoint to add the required report to it.

 

From Acumatica help:

To Add a Report Entity to the Contract of the Endpoint

  1. In the Endpoint Name box, select the name of the endpoint to which you want to add an entity.
  2. In the Endpoint Version box, select the version of the endpoint to which you want to add an entity.
  3. In the left pane, select the Endpoint node.
  4. On the toolbar of the left pane, click Insert, and in the Create Entity dialog box, do the following:
    1. In the Object Name box, type the name of the entity. This is the name of the API object that you will use in the code of your application to work with the entity. Hint:

For details on the characters that can be used in the entity names, see Naming Rules for Endpoints. 2. In the Object Type box, select Report. 3. In the Screen Name lookup box, select the report to which the entity should correspond. 4. Click OK. The Fields tab is populated with the fields for each parameter of the report. 5. Optional: Modify the list of fields, as described in To Add Fields to an Entity.

Almost everything is ready to go.
2. Open Postman, executing login request.

3. Try to execute report request:

  • change Accept to “application/pdf”
  • execute report request
    http://localhost/25.101.0153/entity/DefaultExt/24.200.001/InvoiceMemoReport

    {
    "DocumentType": {"value": "INV"},
    "ReferenceNumber": {"value": "AR014492"}
    }

     

if return code -  202, all OK.
From Acumatica help:
The Location header of the response contains the URL that you can use to obtain the requested report by using the GET HTTP method. When the report is ready, this GET request returns the 200 OK status code. The requested report is returned in the response body.
 

I think this will be helpful.

9 replies

Tony Lanzer
Pro III
Forum|alt.badge.img+2
  • Pro III
  • November 6, 2025

@AllenVaughn , The first thing I would do is change your PUT to a POST. Actions need to be a POST. 


Forum|alt.badge.img+1

Hi ​@AllenVaughn 

 

You are attempting to call the PrintInvoice action on an AR Invoice (SO Invoice) through a custom REST endpoint. The error Invalid URI structure is usually caused not by the JSON, but by an incorrect URL or incorrect action setup in the endpoint.

It’s also important to understand that the standard PrintInvoice action does not accept a printer parameter — it either returns a PDF or prints using the user’s default settings / DeviceHub. If you need to choose a printer, you must implement a custom action.

1️⃣ Correct URI Structure for Actions

The standard REST URL format for calling an action is:

PUT /entity/{EndpointName}/{Version}/{Entity}/{Key}/action/{ActionName}

Example for AR Invoice:

PUT /entity/Default/22.200.001/ARInvoice/Invoice/AR006006/action/PrintInvoice

If you call the action without passing the key in the URL, then you must supply the entity object in the JSON body, and the URL becomes:

PUT /entity/Default/22.200.001/ARInvoice/PrintInvoice

Your JSON is valid:

{
"entity": {
"DocType": { "value": "Invoice" },
"ReferenceNbr": { "value": "AR006006" }
}
}

So the Invalid URI structure error indicates that your endpoint URL or entity/action mapping is incorrect, not the payload.

2️⃣ Why You Cannot Specify a Printer in Standard PrintInvoice

Feature Standard PrintInvoice
Return PDF via API ✅ Yes
Auto-print using default printer / DeviceHub ✅ Yes
Select a specific printer via API ❌ Not supported
Pass { "PrinterName": "Printer01" } from REST API ❌ Not supported

To print to a specific printer, you must:

  1.  Create a custom action on ARInvoiceEntry (ex: PrintToDevice)
  2.  Add a parameter like PrinterName
  3.  Use ReportPrinterJobManager.PrintReport() or PXReportPrinter.Print()
  4.  Publish the action in your custom endpoint
  5.  Call it via REST API

3️⃣ Example Custom Action That Accepts a Printer Name

public class ARInvoiceEntry_Extension : PXGraphExtension<ARInvoiceEntry>
{
public PXAction<ARInvoice> PrintToPrinter;
[PXButton, PXUIField(DisplayName = "Print to Printer")]
public IEnumerable printToPrinter(PXAdapter adapter, string printerName)
{
var invoice = Base.Document.Current;
var parameters = new Dictionary<string, string>
{
["ARInvoice.DocType"] = invoice.DocType,
["ARInvoice.RefNbr"] = invoice.RefNbr
};

ReportPrinterJobManager.PrintReport(
reportID: "AR641000",
parameters: parameters,
printerName: printerName
);

return adapter.Get();
}
}

After exposing this in your custom endpoint, the JSON request becomes:

{
"entity": {
"DocType": { "value": "Invoice" },
"ReferenceNbr": { "value": "AR006006" }
},
"parameters": {
"PrinterName": { "value": "HP_LaserJet_01" }
}
}

4️⃣ Alternative: Download PDF Instead of Printing

If your goal is to print outside Acumatica, it is easier to call the report directly:

POST /entity/Default/22.200.001/report/AR641000
{
"parameters": [
{ "name": "DocType", "value": "Invoice" },
{ "name": "RefNbr", "value": "AR006006" }
]
}

This returns a PDF file, which you can print however you like.

Summary

Goal Solution
Call PrintInvoice and get PDF PUT /action/PrintInvoice
Print automatically to default printer Configure DeviceHub
Print to specific printer Build custom action with PrinterName parameter
Get PDF and control printing outside Acumatica Use /report/AR641000

 

I hope this will be of assistance. 

 


Forum|alt.badge.img+1

@AllenVaughn 

In my previous post, the type and URL of the action call were incorrectly specified.
This is how it should look correctly:
 

POST http://<Base endpoint URL>/SOInvoice/PrintInvoice 

 


  • Author
  • Freshman I
  • November 6, 2025

@aleksejslusar19  Looks exactly like the solution I need.  I’ll give it a go and see how it works.

Thank you for all your help.

Allen Vaughn


  • Author
  • Freshman I
  • November 6, 2025

I’m trying to call the report directly as shown in the last example in your Summary, but I don’t have an entity in an endpoint labeled ‘report’.  Am I reading that incorrectly?  What am I missing?

 


  • Author
  • Freshman I
  • November 6, 2025

Never mind.  I created a new Report entity in my custom endpoint and when I do a post to that endpoint with the supplied entity it returns the location to download the PDF in the Location header of the response.  I can now retrieve a PDF of the invoice.

Thank you for pointing me in the right direction.


  • Author
  • Freshman I
  • November 6, 2025

Another question:  This report process takes a while to generate a new report on the invoice.  Since this invoice is an already existing invoice, is there not some way to go directly to a URL of the PDF copy of an existing invoice or does it regenerate the entire invoice on every request?

If I’m simply wanting to reprint an existing invoice, surely the invoice isn’t generated entirely again just to simply print another copy.


Forum|alt.badge.img+1
  • Jr Varsity III
  • Answer
  • November 6, 2025

@AllenVaughn 
Sorry for the delayed response. I needed time to understand how it works in practice :)
Below are step-by-step instructions.

  1. You need to expand the web service endpoint to add the required report to it.

 

From Acumatica help:

To Add a Report Entity to the Contract of the Endpoint

  1. In the Endpoint Name box, select the name of the endpoint to which you want to add an entity.
  2. In the Endpoint Version box, select the version of the endpoint to which you want to add an entity.
  3. In the left pane, select the Endpoint node.
  4. On the toolbar of the left pane, click Insert, and in the Create Entity dialog box, do the following:
    1. In the Object Name box, type the name of the entity. This is the name of the API object that you will use in the code of your application to work with the entity. Hint:

For details on the characters that can be used in the entity names, see Naming Rules for Endpoints. 2. In the Object Type box, select Report. 3. In the Screen Name lookup box, select the report to which the entity should correspond. 4. Click OK. The Fields tab is populated with the fields for each parameter of the report. 5. Optional: Modify the list of fields, as described in To Add Fields to an Entity.

Almost everything is ready to go.
2. Open Postman, executing login request.

3. Try to execute report request:

  • change Accept to “application/pdf”
  • execute report request
    http://localhost/25.101.0153/entity/DefaultExt/24.200.001/InvoiceMemoReport

    {
    "DocumentType": {"value": "INV"},
    "ReferenceNumber": {"value": "AR014492"}
    }

     

if return code -  202, all OK.
From Acumatica help:
The Location header of the response contains the URL that you can use to obtain the requested report by using the GET HTTP method. When the report is ready, this GET request returns the 200 OK status code. The requested report is returned in the response body.
 

I think this will be helpful.


Forum|alt.badge.img+1

Another question:  This report process takes a while to generate a new report on the invoice.  Since this invoice is an already existing invoice, is there not some way to go directly to a URL of the PDF copy of an existing invoice or does it regenerate the entire invoice on every request?

If I’m simply wanting to reprint an existing invoice, surely the invoice isn’t generated entirely again just to simply print another copy.

I've checked, and it looks like the PDF is only available for a single download