endpoint to get invoice pdfs  Topic is solved

Discussions relating to the REST API of Jiwa 7.

endpoint to get invoice pdfs

Postby aaron_bonntech » Wed Jul 13, 2022 2:28 pm

Hi,

Just wondering whats the endpoint to hit to get an invoice PDF from an InvoiceID?

I tried
/SalesOrders/{$InvoiceID}/Documents
/Debtors/{$DebtorID}/Documents

And both of them returned empty arrays. I know the document is there because my client can see the documents in the JIWA program.

Also this is a sandbox environment im querying against if that helps.
aaron_bonntech
I'm new here
I'm new here
 
Posts: 9
Joined: Fri Jul 08, 2022 11:19 am

Re: endpoint to get invoice pdfs  Topic is solved

Postby Mike.Sheen » Wed Jul 13, 2022 2:48 pm

aaron_bonntech wrote:Hi,

Just wondering whats the endpoint to hit to get an invoice PDF from an InvoiceID?

I tried
/SalesOrders/{$InvoiceID}/Documents
/Debtors/{$DebtorID}/Documents

And both of them returned empty arrays. I know the document is there because my client can see the documents in the JIWA program.

Also this is a sandbox environment im querying against if that helps.


The/SalesOrders/{InvoiceID}/Documents and /Debtors/{DebtorID}/Documents will retrieve a binary file document attached to the sales order or debtor - that's not where you would go to get a PDF of an invoice.

What you want is to call the route to generate a report to PDF and pass the ReportID and report parameters - that route is the /Reports/{ReportID}/PDF/Download route.

You'll need to know the ReportID to use - in our demo data the invoice report has a ReportID of 8ce38d28-d320-4b82-9038-8cf2b1880ca4 - that likely will work with the sandbox you've been given, but you can get a list of reports in the system with the /Queries/SY_Report route : https://api.jiwa.com.au/Queries/SY_Repo ... e,FileName

The report parameters need to also be supplied - typically with an Invoice Report, they use the parameter Pass_SP_InvoiceHistoryID - which needs to be set to the SO_History.InvoiceHistoryID value of the snapshot of the invoice.

Here's what a complete route looks like in our demo data:

https://api.jiwa.com.au/Reports/8ce38d28-d320-4b82-9038-8cf2b1880ca4/PDF/Download?apikey=9vjoF4M5-gYVBWjoFyW9nlQieB9FhxpJkAsRJznB_Ok&ReportParameters={Name:Pass_SP_InvoiceHistoryID,Value:000000000800000000NL}
InvoicePDF_apijiwacomau.png


If you know an InvoiceID but don't know the InvoiceHistoryID, you can look at the InvoiceHistoryID's by doing a GET on /SalesOrders/{InvoiceID} and inspecting the result : https://api.jiwa.com.au/SalesOrders/000 ... ormat=json

From that you can pick out the Histories field, which is a list of History each with an InvoiceHistoryID.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: endpoint to get invoice pdfs

Postby SBarnes » Wed Jul 13, 2022 4:47 pm

Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: endpoint to get invoice pdfs

Postby aaron_bonntech » Fri Aug 26, 2022 5:33 pm

Hi Mike,

Sorry for re-opening this thread. When i call the endpoint, i get an error:

["ResponseStatus"]=>
array(4) {
["ErrorCode"]=>
string(12) "COMException"
["Message"]=>
string(130) "Error in File MNT30000 - Invoice 25876_12052_{C6EFC67B-EAFC-421A-B38B-F2C95B530446}.rpt:
Page header or footer longer than a page."
["StackTrace"]=>
string(539) "[ReportsPDFGETRequest: 8/19/2022 12:06:59 AM]:
[REQUEST: {ReportID:8ce38d28-d320-4b82-9038-8cf2b1880ca4}]
System.Runtime.InteropServices.COMException (0x80000237): Error in File MNT30000 - Invoice 25876_12052_{C6EFC67B-EAFC-421A-B38B-F2C95B530446}.rpt:
Page header or footer longer than a page.
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)"
["Errors"]=>
array(0) {
}
}

Im hitting /Reports/8ce38d28-d320-4b82-9038-8cf2b1880ca4/PDF/Download with parameter: "ReportParameters" => ["Pass_SP_InvoiceHistoryID" => "99608b0907d949519af9"]

Are there more parameters i need to pass?
aaron_bonntech
I'm new here
I'm new here
 
Posts: 9
Joined: Fri Jul 08, 2022 11:19 am

Re: endpoint to get invoice pdfs

Postby Scott.Pearce » Fri Aug 26, 2022 5:35 pm

Can you run the report OK in the desktop Jiwa client for that same invoice?

If you can, then can you export to PDF without error in the desktop Jiwa client?
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: endpoint to get invoice pdfs

Postby Dean_Bonntech » Fri Aug 26, 2022 5:39 pm

Thanks Scott

The error "Page header or footer longer than a page" implies that the issue is related to pagination - not with the data.
Do we need pass any parameters to the function to specify the page size for the function? Is there a default?
User avatar
Dean_Bonntech
I'm new here
I'm new here
 
Posts: 1
Joined: Fri Aug 26, 2022 5:34 pm

Re: endpoint to get invoice pdfs

Postby Mike.Sheen » Fri Aug 26, 2022 5:39 pm

aaron_bonntech wrote:Hi Mike,

Sorry for re-opening this thread. When i call the endpoint, i get an error:

["ResponseStatus"]=>
array(4) {
["ErrorCode"]=>
string(12) "COMException"
["Message"]=>
string(130) "Error in File MNT30000 - Invoice 25876_12052_{C6EFC67B-EAFC-421A-B38B-F2C95B530446}.rpt:
Page header or footer longer than a page."
["StackTrace"]=>
string(539) "[ReportsPDFGETRequest: 8/19/2022 12:06:59 AM]:
[REQUEST: {ReportID:8ce38d28-d320-4b82-9038-8cf2b1880ca4}]
System.Runtime.InteropServices.COMException (0x80000237): Error in File MNT30000 - Invoice 25876_12052_{C6EFC67B-EAFC-421A-B38B-F2C95B530446}.rpt:
Page header or footer longer than a page.
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)"
["Errors"]=>
array(0) {
}
}

Im hitting /Reports/8ce38d28-d320-4b82-9038-8cf2b1880ca4/PDF/Download with parameter: "ReportParameters" => ["Pass_SP_InvoiceHistoryID" => "99608b0907d949519af9"]

Are there more parameters i need to pass?


Hi aaron,

In addition to Scott's suggestions, show us the exact request you are sending - like the exact url (minus the domain name if you like) - what you said you were providing:
"ReportParameters" => ["Pass_SP_InvoiceHistoryID" => "99608b0907d949519af9"]


Is very different to the working example I provided in my earlier comment - it looks like :
ReportParameters=%7BName:Pass_SP_InvoiceHistoryID,Value:000000000800000000NL%7D


If you don't know the exact query string, use something like Fiddler to capture it on the way out.

EDIT: Or, if you have DebugMode enabled for the jiwa api, hiiting /requestlogs should show you the raw request URL's.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: endpoint to get invoice pdfs

Postby aaron_bonntech » Fri Aug 26, 2022 5:49 pm

Mike.Sheen wrote:
aaron_bonntech wrote:Hi Mike,

Sorry for re-opening this thread. When i call the endpoint, i get an error:

["ResponseStatus"]=>
array(4) {
["ErrorCode"]=>
string(12) "COMException"
["Message"]=>
string(130) "Error in File MNT30000 - Invoice 25876_12052_{C6EFC67B-EAFC-421A-B38B-F2C95B530446}.rpt:
Page header or footer longer than a page."
["StackTrace"]=>
string(539) "[ReportsPDFGETRequest: 8/19/2022 12:06:59 AM]:
[REQUEST: {ReportID:8ce38d28-d320-4b82-9038-8cf2b1880ca4}]
System.Runtime.InteropServices.COMException (0x80000237): Error in File MNT30000 - Invoice 25876_12052_{C6EFC67B-EAFC-421A-B38B-F2C95B530446}.rpt:
Page header or footer longer than a page.
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)"
["Errors"]=>
array(0) {
}
}

Im hitting /Reports/8ce38d28-d320-4b82-9038-8cf2b1880ca4/PDF/Download with parameter: "ReportParameters" => ["Pass_SP_InvoiceHistoryID" => "99608b0907d949519af9"]

Are there more parameters i need to pass?


Hi aaron,

In addition to Scott's suggestions, show us the exact request you are sending - like the exact url (minus the domain name if you like) - what you said you were providing:
"ReportParameters" => ["Pass_SP_InvoiceHistoryID" => "99608b0907d949519af9"]


Is very different to the working example I provided in my earlier comment - it looks like :
ReportParameters=%7BName:Pass_SP_InvoiceHistoryID,Value:000000000800000000NL%7D


If you don't know the exact query string, use something like Fiddler to capture it on the way out.


Hi Mike and Scott, thanks for the prompt replies.

The exact url is
Code: Select all
https://japitest.cedarhospitality.com:5452/Reports/8ce38d28-d320-4b82-9038-8cf2b1880ca4/PDF/Download


Im using CURL so the request would be a GET with json string of
Code: Select all
{"query":{"ReportParameters":{"Pass_SP_InvoiceHistoryID":"99608b0907d949519af9"}}}

where 99608b0907d949519af9 is an invoice history id i got from a sales order.
aaron_bonntech
I'm new here
I'm new here
 
Posts: 9
Joined: Fri Jul 08, 2022 11:19 am

Re: endpoint to get invoice pdfs

Postby Mike.Sheen » Fri Aug 26, 2022 5:54 pm

aaron_bonntech wrote:The exact url is
Code: Select all
https://japitest.cedarhospitality.com:5452/Reports/8ce38d28-d320-4b82-9038-8cf2b1880ca4/PDF/Download


Im using CURL so the request would be a GET with json string of
Code: Select all
{"query":{"ReportParameters":{"Pass_SP_InvoiceHistoryID":"99608b0907d949519af9"}}}

where 99608b0907d949519af9 is an invoice history id i got from a sales order.


Your query parameters do not match what we expect, so the generation of the report is deserialising the parameters as though no Pass_SP_InvoiceHistoryID was provided at all, so it's generating a PDF for all sales orders and that's causing your error.

You need to fix your parameters to match what we expect exactly. Refer to the working URL example I provided earlier.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: endpoint to get invoice pdfs

Postby Mike.Sheen » Fri Aug 26, 2022 5:57 pm

FYI - we've recognised the difficulty in providing the report parameters in a query string, so we've got an improvement in the works to support a POST operation which would allow nice request bodies - DEV-7998.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Next

Return to REST API

Who is online

Users browsing this forum: No registered users and 3 guests

cron