"messageKey": "error.validation.verifyDocument.couldNotBeFlattened"
Wednesday, July 14, 2021 at 10:07pmHello,
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?
Reply to: "messageKey": "error.validation.verifyDocument.couldNotBeFlattened"
Thursday, July 15, 2021 at 09:06amHi 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
Reply to: Hi AyshaSingh, Can we…
Sunday, July 18, 2021 at 07:48pmThanks 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: Thanks Duo. With these steps…
Monday, July 19, 2021 at 11:42amHey Duo,
Could you please help with this issue?
Thanks
Reply to: Thanks Duo. With these steps…
Tuesday, July 20, 2021 at 09:46amHi 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
Reply to: Hi Aysha, Please note…
Thursday, August 5, 2021 at 08:26amHey Duo,
Would you please be able to provide an ETA of release of Javascript version of handdrwan string conversion algorithm as we are blocked in our current project?
Thanks,
Aysha
Reply to: Hey Duo, Would you please…
Thursday, August 5, 2021 at 08:34amHi 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
Reply to: "messageKey": "error.validation.verifyDocument.couldNotBeFlattened"
Friday, August 6, 2021 at 08:04amThanks Duo. I'll check this and reach out to you again in case of issues.
Reply to: "messageKey": "error.validation.verifyDocument.couldNotBeFlattened"
Monday, August 16, 2021 at 05:49pmHey 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: Hey Duo, We are developing…
Tuesday, August 17, 2021 at 09:11amHi 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