Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Error 400 - Validation Error, Missing process definition #6

Open
doublesharp opened this issue Mar 28, 2017 · 1 comment
Open

Comments

@doublesharp
Copy link

When creating a package and attaching documents with Blob data from Attachments and Documents I was receiving the following error.

12:32:30:969 EXCEPTION_THROWN [683]|ESignLiveRESTAPIHelper.ESignLiveRestAPIHelperException: Error creating eSignLive package with documents: 400 - Bad Request - {"messageKey":"error.validation.createProcess.missingData","message":"Missing process definition.","code":400,"name":"Validation Error"}

I was able to reproduce the error in ESignLiveExamples.createPackageWithDocumentsExample() by changing the value of BLob b2 from "test" to "test test" like so:

Blob b2 = Blob.valueOf('test test');

And then running the following Anonymous Apex:

ESignLiveExamples.createPackageWithDocumentsExample('Test Package', false, 'Test Description', System.now().addDays(7), 'Test Email Message');

esl sdk error

After adding some debug logging to EsignLiveSDK.createPackageWithBinaries() I was able to trace the problem by decoding the base64 encoded multipart form data which showed that the boundary between the last document and the package payload was not prefixed by a newline, causing it to be read as part of the line before it.

This is the encoded form data:

Ci0tLS0tLVdlYktpdEZvcm1Cb3VuZGFyeTFiTk82MG43RnFQNVdPNHQKQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJmaWxlIjsgZmlsZW5hbWU9InRlc3REb2N1bWVudE9uZSIKQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9wZGYNCg0KdGVzdERvY3VtZW50T25lCiANCg0KCi0tLS0tLVdlYktpdEZvcm1Cb3VuZGFyeTFiTk82MG43RnFQNVdPNHQKQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJmaWxlIjsgZmlsZW5hbWU9InRlc3REb2N1bWVudFR3byIKQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9wZGYNCg0KdGVzdCB0Z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V4dHJhY3RBbmNob3IiOnsid2lkdGgiOjE1MCwidG9wT2Zmc2V0IjowLCJ0ZXh0IjoidGVzdERvY3VtZW50T25lIiwibGVmdE9mZnNldCI6LTQwLCJpbmRleCI6MCwiaGVpZ2h0Ijo0MCwiY2hhcmFjdGVySW5kZXgiOjEyLCJhbmNob3JQb2ludCI6IkJPVFRPTVJJR0hUIn0sImV4dHJhY3QiOmZhbHNlLCJiaW5kaW5nIjoie2FwcHJvdmFsLnNpZ25lZH0ifV19XX0seyJuYW1lIjoidGVzdERvY3VtZW50VHdvIn1dLCJkZXNjcmlwdGlvbiI6IlRlc3QgRGVzY3JpcHRpb24iLCJhdXRvY29tcGxldGUiOmZhbHNlfQ0KDQoNCi0tLS0tLVdlYktpdEZvcm1Cb3VuZGFyeTFiTk82MG43RnFQNVdPNHQtLQ==

Which decodes to

------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="testDocumentOne"
Content-Type: application/pdf

testDocumentOne
 


------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="testDocumentTwo"
Content-Type: application/pdf

test test------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="payload"  

{"roles":[{"type":"SIGNER","signers":[{"name":"firstNamelastName","lastName":"lastName","firstName":"firstName","email":"fnln@test.com","delivery":{"provider":true,"email":true},"auth":{"scheme":"NONE","challenges":[]}}],"reassign":true,"name":"firstNamelastName","id":"firstNamelastName"}],"name":"Test Package","documents":[{"name":"testDocumentOne","approvals":[{"role":"firstNamelastName","fields":[{"type":"SIGNATURE","top":0,"subtype":"FULLNAME","page":0,"left":0,"extractAnchor":{"width":150,"topOffset":-60,"text":"testDocumentOne","leftOffset":-20,"index":0,"height":40,"characterIndex":12,"anchorPoint":"TOPRIGHT"},"extract":false},{"type":"INPUT","top":0,"subtype":"LABEL","page":0,"left":0,"extractAnchor":{"width":150,"topOffset":0,"text":"testDocumentOne","leftOffset":-40,"index":0,"height":40,"characterIndex":12,"anchorPoint":"BOTTOMRIGHT"},"extract":false,"binding":"{approval.signed}"}]}]},{"name":"testDocumentTwo"}],"description":"Test Description","autocomplete":false}


------WebKitFormBoundary1bNO60n7FqP5WO4t--

The problem is resolved by adding a newline in ESignLiveSDK.createPackageWithBinaries() by prefixing the value of String secondHeader with a newline:

String secondHeader = '\n--' + BOUNDARY + '\nContent-Disposition: form-data; name="payload"';

The same fix is applied to ESignLiveSDK.createDocumentWithBinariesAndFields() as well.

@robmtz
Copy link
Member

robmtz commented Apr 11, 2017

@doublesharp - good find and thanks for sharing the fix. We'll take a look at the issue and your fix and will incorporate accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants