suhaibqaiser | Posts: 1

I am getting intermittent issue of validation error in ESign Live using Apex SDK

0 votes
I am using Apex SDK for one of our project in Salesforce and it does work while uploading document binaries. However, randomly on certain times it creates a validation error. This error has something to do with emails because by changing email address this error goes away. I am copying here a JSON response that we get on error. This error is intermittent and only occur randomly. We are trying to get rid of this issues. Any help would be greatly appreciated. We are using a common Sandbox and we do send Sender Id in our request. This error is related to emails for sure. But no description is returned with the error. The same request works sometimes and does not works sometimes. {"packageId":null,"messageKey":"http.status.400","technical":"","entity":null,"message":"Validation Error","code":400,"name":"Validation Error"}

Approved Answer
Chris_Aub | Posts: 14

Reply to: I am getting intermittent issue of validation error in ESign Live using Apex SDK

0 votes
Hi Rob, We are the clients that Suhaib has been working with on our eSignlive implementation. Here is an example of the request when we receive the 400 error:
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="appfile"
Content-Type: application/pdf 

[File data removed]

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

{"status":"SENT","sender":{"id":"senderidinesignlive","email":"[email protected]"},"roles":[{"type":"SIGNER","signers":[{"title":"Consultant","phone":"(506) 756-2382","name":"sender","lastName":"Test","language":"en","firstName":"eSignature","email":"[email protected]","delivery":{"provider":false,"email":false,"download":true},"company":"Company co","auth":{"scheme":"NONE"}}],"reassign":false,"locked":false,"index":0,"id":"Signer_Applicant","emailMessage":{"content":""}},{"type":"SIGNER","signers":[{"title":"Consultant","phone":"(506) 756-2381","name":"sender","lastName":"Tester","language":"en","firstName":"eSignature","email":"[email protected]","delivery":{"provider":false,"email":false,"download":true},"company":"Company co","auth":{"scheme":"NONE"}}],"reassign":false,"locked":false,"index":0,"id":"Signer_Payor","emailMessage":{"content":""}},{"type":"SENDER","signers":[{"title":"Consultant","name":"sender","lastName":"Saleswoman","language":"en","firstName":"Jenny","email":"[email protected]","delivery":{"provider":false,"email":false,"download":true},"company":"Company co","auth":{"scheme":"NONE"}}],"reassign":false,"locked":false,"index":0,"id":"Signer_Agent","emailMessage":{"content":""}}],"opportunityId":"0061100000CnCLMAA3","name":"eSignature Test_1_Document","emailMessage":" ","due":"2016-08-13T18:50:09.330Z","documents":[{"name":"Individual Dental Plan_Application","extract":true,"approvals":[{"role":"Signer_Applicant","name":"Application_0","fields":[{"type":"SIGNATURE","subtype":"FULLNAME","extractAnchor":{"width":175,"topOffset":-110,"text":"Signature of Applicant","leftOffset":0,"index":0,"height":40,"characterIndex":0,"anchorPoint":"TOPLEFT"},"extract":false},{"type":"INPUT","subtype":"LABEL","extractAnchor":{"width":150,"topOffset":-80,"text":"Signature of Applicant","leftOffset":0,"index":0,"height":20,"characterIndex":0,"anchorPoint":"BOTTOMLEFT"},"extract":false,"binding":"{approval.signed}"}]},{"role":"Signer_Payor","name":"Application_1","fields":[{"type":"SIGNATURE","subtype":"FULLNAME","extractAnchor":{"width":175,"topOffset":-100,"text":"Signature(s) of Bank Account","leftOffset":240,"index":0,"height":40,"characterIndex":0,"anchorPoint":"TOPLEFT"},"extract":false},{"type":"INPUT","subtype":"LABEL","extractAnchor":{"width":150,"topOffset":-70,"text":"Signature(s) of Bank Account","leftOffset":240,"index":0,"height":20,"characterIndex":0,"anchorPoint":"BOTTOMLEFT"},"extract":false,"binding":"{approval.signed}"}]},{"role":"Signer_Agent","name":"Application_2","fields":[{"type":"SIGNATURE","subtype":"FULLNAME","extractAnchor":{"width":175,"topOffset":-100,"text":"Agent's Signature","leftOffset":150,"index":0,"height":40,"characterIndex":0,"anchorPoint":"TOPLEFT"},"extract":false},{"type":"INPUT","subtype":"LABEL","extractAnchor":{"width":150,"topOffset":-70,"text":"Agent's Signature","leftOffset":150,"index":0,"height":20,"characterIndex":0,"anchorPoint":"BOTTOMLEFT"},"extract":false,"binding":"{approval.signed}"}]}]}],"description":" ","autocomplete":true} 
B�KKKKKU�X��]�ܛP��[�\�LX��͌�ќT U��K
What is interesting about the request is the boundary at the very end; there seems to be an issue with the encoding. On other requests, the footer boundary looks normal : ------WebKitFormBoundary1bNO60n7FqP5WO4t-- In what situation would that piece not encode properly ? Thanks

robmtz | Posts: 12

Reply to: I am getting intermittent issue of validation error in ESign Live using Apex SDK

0 votes
Hi suhaibqaiser! Do you have a sample request that errored out that you can post here? Please mask/omit email addresses and sensitive data. Thanks! Rob Martinez Managing Director (210) 468-1718 | [email protected] http://hirekadence.com

robmtz | Posts: 12

Reply to: I am getting intermittent issue of validation error in ESign Live using Apex SDK

0 votes
Hi Chris, Thanks for providing a sample request. Taking a look at this now - will post an update shortly. Thanks! Rob

Chris_Aub | Posts: 14

Reply to: I am getting intermittent issue of validation error in ESign Live using Apex SDK

0 votes
Hi Rob, I believe we may have found a fix to the issue, so I thought it might help if I shared my progress. Our testers and myself are currently able to create packages without receiving the error. The cause of our issue was linked to the encoding of the JSON payload, and not the PDF file as we originally thought. I have modified some code in the SDK to cover scenarios where the encoded JSON content ends up with '='. This was being checked with the file in the ESignLiveDocumentUtilities.encodeDocuments method , so I added the same logic to the ESignLiveDocumentUtilities.encodeContent method. BEFORE:
 /**
     * Method to encode the content passed
     */
    public static String encodeContent(String content)
    {
        String contentEncoded = EncodingUtil.base64Encode(Blob.valueOf(content + '\r\n'));
        String last4BytesForContent = contentEncoded.substring(contentEncoded.length()-4,contentEncoded.length());
        if(contentEncoded.endsWith('=='))
        {
            last4BytesForContent = last4BytesForContent.substring(0,2) + '0K';
            
            contentEncoded = contentEncoded.substring(0,contentEncoded.length()-4) + last4BytesForContent;
        }

        return contentEncoded;
    }
AFTER:
    /**
     * Method to encode the content passed
     */
    public static String encodeContent(String content)
    {
        String contentEncoded = EncodingUtil.base64Encode(Blob.valueOf(content + '\r\n'));
        String last4BytesForContent = contentEncoded.substring(contentEncoded.length()-4,contentEncoded.length());
        if(contentEncoded.endsWith('=='))
        {
            last4BytesForContent = last4BytesForContent.substring(0,2) + '0K';
            contentEncoded = contentEncoded.substring(0,contentEncoded.length()-4) + last4BytesForContent;
        } else if( last4BytesForContent.endsWith('=')) {
            last4BytesForContent =  last4BytesForContent.substring(0,3) + 'N';
            contentEncoded = contentEncoded.substring(0,contentEncoded.length()-4) + last4BytesForContent;
        }

        return contentEncoded;
    }
This might not cover all scenarios, but it's progress.

robmtz | Posts: 12

Reply to: I am getting intermittent issue of validation error in ESign Live using Apex SDK

0 votes
Hey Chris, Great find! I'm glad you got it working. We were working to replicate the error. I'll look into including this update in the SDK. Thanks, Rob Martinez

robmtz | Posts: 12

Reply to: I am getting intermittent issue of validation error in ESign Live using Apex SDK

0 votes
Hey Chris, Just a quick update.. We've included your fix in the SDK (Github repo and unmanaged package). Thanks! Rob Martinez

Chris_Aub | Posts: 14

Reply to: I am getting intermittent issue of validation error in ESign Live using Apex SDK

0 votes
That's great to hear! Thanks again

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