ratna.p.kandi | Posts: 9

PL SQL send pdf file via rest api

0 votes

PL SQL send pdf file via rest api

Getting below error while trying to send pdf file via rest api using Oracle utl_http

Response> Status Code: 500
Response> Reason Phrase: Internal Server Error
Response> HTTP Version: HTTP/1.1


ratna.p.kandi | Posts: 9

Reply to: PL SQL send pdf file via rest api

0 votes

PFA for the code snippet


Duo_Liang | Posts: 3776

Reply to: PL SQL send pdf file via rest api

0 votes

Hi ratna.p.kandi,

 

Thanks for the information, your request raw body looks fine to me. At the same time, I doubt that the 500 error comes directly from OSS server. In your code, are you also setting the API URL as "https://dxxxv/api/packages/" instead of "sandbox.esignlive.com" and is it a reverse proxy set up internally? Are you able to directly connect to sandbox.esignlive.com to make sure the response coming from OSS server?

 

Duo


ratna.p.kandi | Posts: 9

Reply to: PL SQL send pdf file via rest api

0 votes

Thank you Duo for the response. Yes, I am setting the URL as "https://dxxxv/api/packages/", this is an Dsign Development/SIT instance for our Organization. I am invoking this API call from Our Dev Oracle Server using PL/SQL UTL_HTTP. Please, can you share the IP Address for "sandbox.esignlive.com" servers hosting the API calls. 

For your reference, I am attaching the pdf document and I am having no issues uploading it from UI. Also, the code snippet.

 

Thanks,

Ratna.

 


Duo_Liang | Posts: 3776

Reply to: PL SQL send pdf file via rest api

0 votes

Hi Ratna,

 

What's the URL of your UI portal? Or can I have an example package ID to locate your account?

 

Duo


ratna.p.kandi | Posts: 9

Reply to: PL SQL send pdf file via rest api

0 votes

Hi Duo,

The package on Sandbox. Package ID :  fBfQWq45eC2EYYgbNqRKdwzZmmU=

 

Internal Dsign for our organization

URL for API Calls :  https://dxxxv
URL for UI : https://txxxv/ISA/login
Package ID on Internal Dsign : zGE3p5rXjHJ33kYROmrjBTlBGJU=

Thanks,

Ratna.


Duo_Liang | Posts: 3776

Reply to: PL SQL send pdf file via rest api

0 votes

Hi Ratna,

 

Thanks for the background information! Yes, our support agent confirms that your organization has an on-premise instance. 

Could you either test the connection against your on-premise environment with a GET or simple POST call first, or try the code base with sandbox environment (you can find the IP address of all OSS instances in this guide)? 

 

PS: Just FYI that I also have a blog series about PL/SQL integration:

https://www.onespan.com/blog/onespan-sign-developer-integrate-oracle-plsql-part-1

https://www.onespan.com/blog/onespan-sign-developer-integrate-oracle-plsql-part-2

https://www.onespan.com/blog/onespan-sign-developer-integrate-oracle-plsql-part-3

https://www.onespan.com/blog/onespan-sign-developer-integrate-oracle-plsql-part-4

 

Duo

 


ratna.p.kandi | Posts: 9

Reply to: PL SQL send pdf file via rest api

1 votes

Hi Duo,

Could you either test the connection against your on-premise environment with a GET or simple POST call first,

Yes, we are able to establish a connection from Oracle Server to On-prem Dsign SIT environment. In fact, we had created multiple packages using POST, and also qurey those packages using GET method. Unfortunately, we are facing issues with attach document API with 500 (Internal Server error). 

or try the code base with sandbox environment (you can find the IP address of all OSS instances in this guide)? 

I doubt if we can connect to sandbox (i.e external network) from our Internal Oracle Servers. Not sure, if our security team would allow or this request. Hope you understand this limitation on our end.

 

Thank you for the documentation provided for PL/SQL integration, I will go through it and check if I am missing anything.

Thanks,

Ratna.


ratna.p.kandi | Posts: 9

Reply to: PL SQL send pdf file via rest api

0 votes

Hi Duo,

Thank you for the documentation on PL/SQL integration. I have gone through provided integration documents & examples. Everything is coved in our code, please let us know still why we are getting the 500 (Internal Server Error) ?

 

Thanks,

Ratna. 


Duo_Liang | Posts: 3776

Reply to: PL SQL send pdf file via rest api

0 votes

Hi Ratna,

 

I think I might find the issue - I noticed that in your raw request, there are two new lines after the PDF binary, see attachment. Could you make it one new line and see if it makes any difference?

 

PS: I attached the code works at my end where I removed the extra newline.

 

Duo

 


Duo_Liang | Posts: 3776

Reply to: PL SQL send pdf file via rest api

0 votes

+attachments.


Attachments
ratna.p.kandi | Posts: 9

Reply to: PL SQL send pdf file via rest api

0 votes

Hi Duo,

 

I have tried the same PL/SQL code that you have provided. Still no luck. Getting below error,

{"code":500,"message":"Unexpected error. We apologize for any inconvenience this may have caused you, please try again. If the problem persists, please contact our support team.","messageKey":"error.internal.default","name":"Unhandled Server Error"}
 

For your reference I have attached the zip file with the code, output and also the sample pdf file used. Also, please can you send me the pdf file that you have used, want to try with that one too. Likewise can you try with the PDF that I have provided ?

PS.. I am having no issues uploading the same PFD from UI.

 

Thanks,

Ratna.


Duo_Liang | Posts: 3776

Reply to: PL SQL send pdf file via rest api

0 votes

Hi Ratna,

 

Two things-

#1 Not sure why, but when i upload your PDF directly to US2 sandbox (it's deployed with the latest OSS SaaS environment), it says your PDF was locked. It works when I resaved your PDF in Adobe Acrobat as attached.

#2 I uncommented the line 55 and 80 

 

Duo


ratna.p.kandi | Posts: 9

Reply to: PL SQL send pdf file via rest api

0 votes

Hi Duo,

 

Thank you for providing the details. This new PDF worked and I was able to upload the PDF to a packages using API. Thanks a lot for finding the issue.

The PDF that I have provided was generated from our Oracle Servers. Was there any issue in how those PDF's got generated? Please, let us know what should be the workaround.

 

Thanks,

Ratna.


Duo_Liang | Posts: 3776

Reply to: PL SQL send pdf file via rest api

0 votes

Hi Ratna,

 

I am not an expert in PDF, but when I tried to analyze the original PDF with the preflight tool in Acrobat DC, it said the document structure is corrupt, see attachment. Try to regenerate another PDF from your Oracle server, or you can consult with your team which works with the document generation.

 

Duo


Attachments
ratna.p.kandi | Posts: 9

Reply to: PL SQL send pdf file via rest api

1 votes

Thank You Duo. Now, all our issues have been fixed.


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off