-
Notifications
You must be signed in to change notification settings - Fork 162
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
How should I use EnvelopesApi.UpdateDocument? #357
Comments
Hello, I'm Gloriana from DocuSign Developer Support. I'll be happy to assist with this, would you be able to provide a complete code snippet (without exposing any sensitive information) so we can have better context for this issue? Thank you. |
The main issue is that var envelopeApi = new EnvelopesApi(apiClient);
// where do file bytes and name go?
var res = envelopeApi.UpdateDocument(accountId, "<envelope id>", "1"); |
Hi @eg-bernardo, you are correct on this, the SDK method is wrong and has been reported internally as a bug. In this case, you will have to add new documents and delete old documents with the SDK method while this is looked into internally. |
and update on this? |
I debugged this and found that the issue is with UpdateDocumentWithHttpInfo method inside UpdateDocument method call. Not sure if the above is the correct value for a PDF. Please have the correct value in place and update the fix ASAP. Below is the error we get while making call to UpdateDocument method:- Exception - Thanks |
any updates on this? |
Resolving the bug such that EnvelopesApi.UpdateDocument correctly attempts to set the Content-Disposition header will reveal another far more insidious bug in SystemNetHttpClient.BuildRequestMessage where the line |
@aaston86 Sure if that works well and good. @GlorianaMarinDS - any update as to when this will be fixed. |
HT @lukasparsons for the collab... In case it helps someone else, here is how we are working around this issue: protected async Task UploadOrReplaceDocument(string envelopeId, string documentId, byte[] bytesToUpload, string fileName)
{
HttpRequestMessage request;
try
{
request = new HttpRequestMessage(HttpMethod.Put,
$"{_requestItemsService.ApplicationSession.BasePath}/restapi/v2.1/accounts/{_docuSignJwtSettings.AccountId}/envelopes/{envelopeId}/documents/{documentId}");
request.Headers.Add("Authorization", $"Bearer {_requestItemsService.ApplicationUser.AccessToken}");
var content = new ByteArrayContent(bytesToUpload);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") { FileName = fileName };
request.Content = content;
// If or when this GitHub issue is resolved, we may be able to switch to the following single line version of the above.
// https://github.com/docusign/docusign-esign-csharp-client/issues/357
//EnvelopeDocument response = await EnvelopesApi.UpdateDocumentAsync(_docuSignJwtSettings.AccountId, envelopeId, documentId, bytesToUpload);
}
catch (Exception e)
{
Log.Error("Error occurred preparing DocuSign request for uploading replacement pdf", e);
throw;
}
// ... method continues
} |
I'm talking about this method: https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopedocuments/update/
There it says:
but the signature of the method is:
Calling that method as is, returns:
I've also tried to provide the file by replacing the
RestClient
, and adding this to theIRestRequest
using:but then I get:
The text was updated successfully, but these errors were encountered: