docusign / docusign-esign-java-client

The Official Docusign Java Client Library used to interact with the eSignature REST API. Send, sign, and approve documents using this client.
https://javadoc.io/doc/com.docusign/docusign-esign-java/latest/index.html
MIT License
105 stars 96 forks source link

JSON parsing failing on web hook handler #215

Closed ccnokes closed 2 years ago

ccnokes commented 2 years ago

I have a DocuSign connect web hook handler that looks like this:

@RequestMapping(value="/docusign/event", method = RequestMethod.POST)
    public void handleDocusignWebhookEvent(@RequestBody Envelope envelope) {
        LOG.info("webhook request received for envelope {} with status {}", envelope.getEnvelopeId(), envelope.getStatus());
    }

But it fails on the JSON parse step. When I inspect the payload it receives vs the classes it tries to parse to, it looks like the PDFBytes property doesn't exist in EnvelopeDocument and there's no ignore unknown properties annotation, so it fails. That's my best guess. I'm new to Java development 😅. I have the include documents option enabled on my connect web hook configuration but when I disable it, it works.

ccnokes commented 2 years ago

I put together a test case demonstrating it here: https://replit.com/@ccnokes/InternationalAttentiveVisitors#Main.java

That might take awhile to run, but the the output is this:

it works! the envelope id is: e97e5c95-9c23-49f7-9628-9977f71fc162
error Unrecognized field "PDFBytes" (class com.docusign.esign.model.EnvelopeDocument), not marked as ignorable (26 known properties: "display", "authoritativeCopy", "signerMustAcknowledge", "documentBase64", "name", "uri", "attachmentTabId", "order", "containsPdfFormFields", "displayMetadata", "authoritativeCopyMetadata", "documentFields", "availableDocumentTypes", "documentId", "signerMustAcknowledgeMetadata", "templateRequired", "errorDetails", "addedRecipientIds", "includeInDownloadMetadata", "sizeBytes", "includeInDownload", "nameMetadata", "documentIdGuid", "pages", "templateLocked", "type"])
 at [Source: (BufferedInputStream); line: 92, column: 26] (through reference chain: com.docusign.esign.model.Envelope["envelopeDocuments"]->java.util.ArrayList[0]->com.docusign.esign.model.EnvelopeDocument["PDFBytes"])

So when that PDFBytes property is removed, it works. Let me know if you need any more info!

mmallis87 commented 2 years ago

@ccnokes First of all I apologize that your concern wasn't addressed in a timely fashion. It must has fallen between the cracks.

Adding this statement to the ObjectMapper will ignore extra fields such as PDFBytes, if that's an acceptable behavior for you: mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

Here the fully working example: https://replit.com/@mmallis87/InternationalAttentiveVisitors#EnvelopeReader.java