AyshaSingh

"messageKey": "error.validation.verifyDocument.couldNotBeFlattened"

0 votes

Hello,

We are trying to sign document using API api/packages/{packageId}/documents/signed_documents and passing "handdrawn" string in request body.

We are using CAPTURE subtype while creating package as our requirement is to capture the signature passed in handdrawn as base64 string. But while calling signed_documents API , I am getting 

"code": 400, "messageKey": "error.validation.verifyDocument.couldNotBeFlattened", "message": "Could not upload PDF document: it contains a syntax error preventing proper processing of its data.", "name": "Validation Error".

Could you please suggest what might be the issue?


Attachments

Reply to: "messageKey": "error.validation.verifyDocument.couldNotBeFlattened"

0 votes

Hi AyshaSingh,

 

Can we make sure the error happens when bulk signing for capture signatures? Because from the error message "Could not upload PDF document: it contains a syntax error preventing proper processing of its data.", it seems your API is uploading a document while the OneSpan Sign document engine can't flatten it.

If you do a quick test in Postman:
(1)Create a transaction with the payload you've attached - remember to set the "status":"SENT"

(2)Retrieve a signer authentication token for signer1:
POST /api/authenticationTokens/signer/multiUse

with payload {"packageId":"your_package_id","signerId":"email_of_applicant"}

(3)Get a session token from signer authentication token

GET https://sandbox.esignlive.com/auth?signerAuthenticationToken={the_signer_authentication_token_generated_from_step2}

Notice there's no /api/ in the URL

(4)Bulk sign for capture signature

POST /api/packages/{packageId}/documents/signed_documents

Cookie: ESIGNLIVE_SESSION_ID={sessionToken_generated_from_step3}

with payload { "documents": [ { "id": "default-consent" } , { "id": "prev1626196936031525468" } ], "handdrawn": "AQAAAAIcDeoYTaHiVvjKkwDJLWb6AFAAAwADADkAAAADAAAA+gBQABoAAAACRQaAQAdiEkAeQBmChTITI4BQF1Aon1CBRAhErESGVFVQ6FCVUHNQc4iamYQ=" }

And most likely you won't hit the same 400 error as you are experiencing.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to:

0 votes

Thanks Duo. With these steps I was able to bulk sign the documents with this sample handdwawn string.

However , I am not able to sign with my own handdrawn string. We have created a html canvas to capture signer's signature and we want to convert the captured signature into a valid handdrawn string which will be sent in signing API while bulk signing.

Could you please suggest a way to convert canvas image to acceptable format of handdrawn string? Is the handdrawn string of a different format? How can i create it?

Aysha


Reply to:

0 votes

Hi Aysha,

 

Please note that you won't be able to direct use the base64 string of an image as handdrawn value since OneSpan Sign is using a different algorithm to encode the signature strokes.

We do have code shares in Java, .NET or PHP which convert a jpeg or bmp image to the base64 string. I am also developing on an pure Javascript example that you can directly represent in an HTML canvas, but I will have to run the code by the project management team before I can release it on Code Share.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to:

0 votes

Hi Aysha,

 

Here's an example how you could convert the hand drawn into base64 string and vice versa - you can directly open the html in a browser and see the output immediately.

However, please be aware that this is just a sample code and probably won't be officially maintained and supported by OneSpan Sign. From community's perspective, if you potentially encountered any problem using the sample code, I will still try my best to help you fixed the issue.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Attachments

Reply to: "messageKey": "error.validation.verifyDocument.couldNotBeFlattened"

0 votes

Thanks Duo. I'll check this and reach out to you again in case of issues.


Reply to: "messageKey": "error.validation.verifyDocument.couldNotBeFlattened"

0 votes

Hey Duo,

We are developing bulk signing functionality using steps mentioned at this link https://community.onespan.com/documentation/onespan-sign/guides/feature-guides/developer/bulk-signing-signer

The first two steps of Signer Authentication and Session Token are obtained in the backend using API key. We would like to invoke the signed_documents API from the browser (using Session Token returned from the backend) . Please note we are still sending cookie value - ESIGNLIVE_SESSION_ID=${sessionToken}.

To implement this we are using XMLHttpRequest in our script. We face CORS error as we are hitting from our domain. However we are facing 405 method not found when the browser sends the CORS preflight request as it seems OPTIONS is not allowed. Would we need our domain whitelisted to allow cross domain?

Could you please suggest how could we call POST api/signed_documents from browser? 

Thanks

Aysha

 


Reply to:

0 votes

Hi Aysha,

 

The third step "POST /api/packages/{packageId}/documents/signed_documents" shouldn't be invoked from browser, but still from your backend. This call needs to carry a cookie header (instead of using account owner's API Key) in order to mimic a signer behavior .

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


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