Thomas_Lang | Posts: 8

Upload PDF in binary format using Postman

0 votes

Hi,

in our IT-system(SAP) we have the PDFs, that  we want to send to OneSpan, stored in a table in binary format.

Since we don't have the actual file... how can I implement an example in Postman? 

I mean how can I send a PDF in binary format via Postman to OneSpan?


Duo_Liang | Posts: 3776

Reply to: Upload PDF in binary format using Postman

0 votes

Hi Thomas,

 

Are you directly accessing the database, if so, does the PDF be encrypted by data key before being stored? Does SAP provide any UI portal or API/SDK capability to download the stored file?

Is the binary format in a hex representation like "0x433A5C55736535" or a byte array like "01110100"? - I doubt you can directly pass byte array into Postman, but I believe you can implement some script to convert the byte array back to file, but as the foregoing stated, not sure if the data has been encrypted.

 

Duo


Thomas_Lang | Posts: 8

Reply to: Upload PDF in binary format using Postman

0 votes

Hi Duo,

I directly access the database, the PDF code starts like "255044462D312E350D0A25B5B5B5B50D0A312030206F626A0D0A3C3C2F547970652F436174616C6F67", I don't think it's encrypted. For DocuSign I can just transform it to Base64 and then enter that code in Postman into the body: 

{
  "documents": [
    {
      "documentBase64": "JVBERi0xLjUNCiW1tbW1(...)

I don't neccessarily need Postman, I just use it to rebuild what I did there in ABAP. So if you can provide a coding for ABAP that sends a PDF stored in a table to OneSpan, that would be even better.


Duo_Liang | Posts: 3776

Reply to:

0 votes

I see.

First, you'd need to adjust the code base and send a POST "multipart/form-data" call (JSON payload named "payload", PDF named "file") instead of "application/json" for the transaction creation. This is because OneSpan Sign API doesn't allow the document binary to be passed as part of the JSON payload. As a quick test, you don't need to read the data from table, but to hardcode the content like "some sample text", OneSpan Sign would create a A4 size blank document with these text stamped.

As the second step, you just need to decode the final base64 string - for example, JVBERi0xLjUNCiW1tbW1 after decoding:

%PDF-1.5
%

......

And pass the decoded string to the post call.

 

Duo

 


Thomas_Lang | Posts: 8

Reply to:

0 votes

Hi Duo,

 

it works fine with the "some sample text", it also works with an uploaded file, but it doesn't work with the binary code. 

%PDF-1.5
%µµµµ
1 0 obj
<</Type/Catalog/Pages 2 0 R/Lang(de-DE) /StructTreeRoot 17 0 R/MarkInfo<</Marked true>>>>
endobj
2 0 obj
<</Type/Pages/Count 1/Kids[ 3 0 R] >>
endobj
3 0 obj
<</Type/Page/Parent 2 0 R/Resources<</ExtGState<</GS5 5 0 R/GS8 8 0 R>>/Font<</F1 6 0 R/F2 9 0 R/F3 12 0 R/F4 14 0 R>>/XObject<</Meta11 11 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 595.32 841.92] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S/StructParents 0>>
endobj
4 0 obj
<</Filter/FlateDecode/Length 4060>>
stream
xœÕ]ÝnÛF¾7àwà%YÄcÎ?YâØIÝmÚ4qZ`Ó¢eú§kK©D'h_l§7}†½ÊŞs†”d“#‰âHÝma[¤†ü¾9sæü͐9|:)o.Ã2úâ‹Ã§e9^ѻóñûŸÏ~_¾\݌åÍxtøæþ¼ÄS_ƒ‹bòå—ÑÑñ³èðÅ]M÷÷

(...)

Please also see attachments.


Duo_Liang | Posts: 3776

Reply to:

0 votes

I actually meant to set the value in ABAP directly. 

In Postman, directly upload a PDF should be equivalent to sending binary code in text. However this won't work because when building the request body, Postman ate the line break before and after the PDF binary even if I've inserted enter - if you check the raw request body in Postman console (view > Show Postman Console > show raw log), it appears as such:

3-31-3

But it shouldn't be a problem if you invoked POST multipart/form-data call from HTTP client provided by ABAP.

 

Duo


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