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
107 stars 97 forks source link

411 Error thrown from BulkEnvelopesAPI updateRecipients call #98

Closed ckasek closed 5 years ago

ckasek commented 5 years ago

I'm trying to send bulk requests with the Java SDK, based on the code here:

https://github.com/docusign/docusign-java-client/blob/ab83aa8b59a9d7b0232c8a5cbad52ae8995fe3a6/src/test/java/SdkUnitTests.java#L1319

This code on it's own works, but as soon as I try to add BulkRecipientTabLabels to the BulkRecipients, it bombs with:

Error while requesting server, received a non successful HTTP code 411 with response Body: 
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>'

Is this API call expected to work when you provide tab labels? Is there something else that needs to be done?

testCode.txt

ckasek commented 5 years ago

I got a more specific error message from the sample app I sent to your developer support:

com.fasterxml.jackson.dataformat.csv.CsvMappingException: CSV generator does not support Object values for properties (nested Objects) (through reference chain: com.docusign.esign.model.BulkRecipient["tabLabels"]->java.util.ArrayList[0])

I'm also attaching my example here. You'd need to plug in your own credentials. example.zip

mmallis87 commented 5 years ago

@ckasek Thank you for reporting this. We will look into this and give you a fix (or workaround) within 2 weeks.

mmallis87 commented 5 years ago

@ckasek DocuSign API doesn't seem to allow to update the recipients tabLabels field in bulk, although the SDK model. The workaround is to loop through the recipients and call EnvelopesApi.updateRecipients. We will fix the model and the docs to make this clear.

@LarryKlugerDS anything to add? @gsnavin @RajRele @acooper4960 FYI!

ckasek commented 5 years ago

@mmallis87 Why are you closing the issue? Having to call updateRecipients for hundreds of recipients is not a workaround and defeats the entire purpose of have a bulk sending API. From reading the API documentation, it would appear that the API itself supports this, it's the SDK that has a bug in trying to convert the bulk recipients object into a CSV file. Why can't you find a working way to convert the object into a CSV file as intended?

LarryKlugerDS commented 5 years ago

Hi @ckasek,

Can you say more what your use case is--in other words, why do you need to update a bulk set of envelopes once you've sent them?

The primary bulk send API use case is to create a set of recipients (the csv) and then create/send envelopes for those recipients in bulk. -- fire and forget.

If you want the individual envelopes to have more differences than just the recipients, I'd suggest creating each one separately via Envelopes::create.

If the issue is that you don't want to synchronously wait for each envelope to be created, you can use the asynchronous setting of the envelope request model.

Re: closing this bug report

Have you tested an update of a bulk send request using the API directly? (Via postman or equivalent?) That would be the next thing to try. If it works then there's a problem in the SDK.

My reading of @mmallis87's comment is that his investigation showed that the underlying API does not support an update of the bulk send object in the way that you want.

If you'd like me to submit an enhancement request with the bulk send team, please provide the use case details as discussed above.

Many thanks, Larry

ckasek commented 5 years ago

@LarryKlugerDS @mmallis87 I understand the primary use case of the bulk send API, which is exactly what I'm trying to do. I'm not trying to have more differences than just the recipients - I just want to be able to specify my recipients with their tabLabels so the template is pre-populated (which is the whole reason we use templates). It has nothing to do with synchronous vs asynchronous or making updates after the request is sent.

The underlying API does support an update of the bulk recipients in the way I want - I can already do this using your web UI, by uploading a CSV file. I can also do this by calling the API directly via Postman. I cannot do this using your Java SDK, because your code to generate the CSV file based on the bulk recipients object bombs.

The use case is that I want to send a template out to a large amount of signers, and pre-populate data in that template based on the person I'm sending it to. For instance, I will have a template that I want to send out to hundreds of employees who are on the ground around the world, to acknowledge their assignments. In this template, I will have fields for things such as the contract they are assigned to, the base they are working out of, their point of contact at that base, etc. This is information that is different for every recipient. I want to use the bulk recipients api to provide all of this at once, so I don't have to make hundreds of API calls.

To try and make this as straightforward as possible. In the BulkEnvelopesApi.updateRecipients call, it sets the content-type to 'text/json'. The chain then goes to ApiClient.invokeApi -> ApiClient.getAPIResponse. From here, there's an if statment that will end up calling ApiClient.serialize, which based on the content type being 'text/json', will call ApiClient.serializeToCsv. This is where things break, with the Jackson error I've provided in the second comment.

LarryKlugerDS commented 5 years ago

Hi @ckasek, Thank you for your message. I had not previously understood some of the situation.

I have re-opened the issue and re-opened the internal bug report.

Can you supply a screenshot from Postman, or a copy of the request/response from the DocuSign logging system that shows the successful API call that does not use the SDK?

DocuSign logger: https://support.docusign.com/guides/ndse-user-guide-api-request-logging

Thank you, Larry

ckasek commented 5 years ago

@LarryKlugerDS is there any update on this issue?

LarryKlugerDS commented 5 years ago

I think the best solution is to use the new BulkAPI which is supported in v2.1 of the REST API.

The API has initial documentation here: https://developers.docusign.com/esign-rest-api/guides/concepts/envelopes/bulk-send

Please check it out and let us know if it helps.

All demo accounts should have access to REST API v2.1.

mmallis87 commented 5 years ago

@ckasek now with 2.11.0 and 3.1.0 you can pass a csv byte array to this API method. Here is an example: https://github.com/docusign/docusign-java-client/blob/master/src/test/java/SdkUnitTests.java#L1286-L1294

mmallis87 commented 5 years ago

There was no activity since June, so this will be closed as resolved. Feel free to reopen if you have a reason to believe that the issue not resolved.