0
        string accountId = "60194631-4f3e-4684-ba08-3304476b12f3";
        string envelopeId = "1";
        string documentId = "3";
        string encoding = "base64";

DocuSign.eSign.Api.IEnvelopesApi.GetDocument(accountId, envelopeId, documentId,) 

I tried this and it gives me an error

safern
  • 9
  • 1

1 Answers1

0

You cannot call an interface in C# directly.

The code you need for this is this (can be found here - https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/eSignature/Examples/GetDocumentFromEnvelope.cs):

    var docuSignClient = new DocuSignClient(basePath);
    docuSignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(docuSignClient);
    
// Step 1 start
// Step 1. EnvelopeDocuments::get.
// Exceptions will be caught by the calling function
Stream results = envelopesApi.GetDocument(accountId, envelopeId, documentId);
// Step 1 end
    
// Step 2 start
// Step 2. Look up the document from the list of documents
EnvelopeDocItem docItem = documents.FirstOrDefault(d => documentId.Equals(d.DocumentId));
    
// Process results. Determine the file name and mimetype
string docName = docItem.Name;
bool hasPDFsuffix = docName.ToUpper().EndsWith(".PDF");
bool pdfFile = hasPDFsuffix;
    
// Add .pdf if it's a content or summary doc and doesn't already end in .pdf
string docType = docItem.Type;
if (("content".Equals(docType) || "summary".Equals(docType)) && !hasPDFsuffix)
{
    docName += ".pdf";
    pdfFile = true;
}
    
// Add .zip as appropriate
if ("zip".Equals(docType))
{
    docName += ".zip";
}
    
// Return the file information
// See https://stackoverflow.com/a/30625085/64904
string mimetype;
if (pdfFile)
                {
                    mimetype = "application/pdf";
                }
                else if ("zip".Equals(docType))
                {
                    mimetype = "application/zip";
                }
                else
                {
                    mimetype = "application/octet-stream";
                }
    
                return (results, mimetype, docName);
Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23
  • I did that code, However I'm getting a error that the access token is invalid. To be clear I still have a few hours for the access token to expire . – safern Mar 01 '23 at 16:32
  • string accessToken = "eyJ0eXAiOiJNVCIsImFsZyI6IlJTMjU2Iiwia2lkIjoiNjgxODVmZjEtNGU1MS00Y2U5LWFmMWMtNjg5ODEyMjAzMzE3In0"; string BasePath = "https://demo.docusign.net/restapi"; string AccountId = "07d18190-a111-4d94-9388-2d9dd8013384"; string EnvelopeId = "9ECBFD08-AC1E-46C1-A2A5-9AA48EA8D5A8"; string DocumentId = "3"; List documents; GetDoc(accessToken, BasePath, AccountId, EnvelopeId, DocumentId, doc.Documents ) ; – safern Mar 01 '23 at 16:33
  • You should not hardcode access tokens, not sure how you know you still have a few hours, if it says it expired - then it expired. You need to get them dynamically using OAuth so it's a fresh token every time – Inbar Gazit Mar 01 '23 at 17:00