2017-03-29 5 views
0

Wir versuchen unten auszuführen: Im Programm mit C# DocuSign API REST Version SDK, Sie versuchen, einen Umschlag mit einer Vorlage zu erstellen, Zu diesem Zeitpunkt, in der Feld in der Vorlage definiert, Ich möchte Werte aus dem Programm eingeben. (Die Vorlage enthält das Feld der Signaturmarkierung.)Ich kann die EnvelopeTabs Liste erhalten

■ Ausgabe Um eine Liste von DocuSign Feldern zu erhalten, Die API (EnvelopeTabs: Liste) ausgegeben wird, 【Coding Beispiel】 Tabs tabs = UmschlägeApi.ListTabs (accountId, envelopeSummary.EnvelopeId, "1");

Folgefehler aufgetreten. Durch Angeben einer Vorlage wird die in dieser Vorlage definierte Feldliste Der folgende Fehler trat beim Erfassen auf.

"Fehler beim Umwandeln von Wert 1 in den Typ 'DocuSign.eSign.Model.Number'. Pfad 'signHereTabs [0] .scaleValue', Zeile 6, Position 23.“

■ Spezifische Implementierungsdetails Veröffentlicht von DocuSign · CoreRecipes.cs Wir haben die folgenden.

  1. Am Ende der requestSignatureOnDocumentTest Methode von CoreRecipes.cs, den folgenden Code hinzufügen eine Liste der Registerkarten zu bekommen. Registerkarte Tabs = UmschlägeApi.ListTabs (accountId, envelopeSummary.EnvelopeId, "1");

  2. in der Methode Main von CoreRecipes.cs, // *** TEST 1 - Antrag Unterschrift (auf lokales Dokument) EnvelopeSummary envSummary = recipes.requestSignatureOnDocumentTest(); durchgeführt.

■ Weitere Informationen Wenn das Unterschriftsfeld nicht (zB Feld A, Feld B, Feld C) vorhanden ist, können Sie das Feld Liste, Im Fall Wenn das Unterschriftsfeld existiert (ZB Feld A, Feld B, Feld C, Unterschriftsfeld), Es wird ein Fehler zurückgegeben, der nicht erfasst werden kann.

+0

Können Sie die rohen API Request/Response schreiben Sie senden/empfangen? Das hilft viel schneller zu diagnostizieren. Wenn Sie nicht sicher sind, wie Sie Ihre API-Protokolle erhalten, lesen Sie diesen Blogpost: https://www.docusign.com/blog/checking-api-logs-like-the-weather/ – Ergin

Antwort

1

CoreRecipes.cs (Unser Source Code)

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.IO; 
using Newtonsoft.Json; 

using DocuSign.eSign.Api; 
using DocuSign.eSign.Model; 
using DocuSign.eSign.Client; 

namespace TestProj 
{ 
    class CoreRecipes 
    { 
     // Integrator Key (aka API key) is needed to authenticate your API calls. This is an application-wide key 
     private string INTEGRATOR_KEY = "[INTEGRATOR_KEY]"; 

     ////////////////////////////////////////////////////////// 
     // Main() 
     ////////////////////////////////////////////////////////// 
     static void Main(string[] args) 
     { 
      CoreRecipes recipes = new CoreRecipes(); 

      //*** TEST 1 - Request Signature (on local document)    
      EnvelopeSummary envSummary = recipes.requestSignatureOnDocumentTest(); 

      Console.Read(); 
     } 

     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
     public EnvelopeSummary requestSignatureOnDocumentTest() 
     { 
      // Enter your DocuSign credentials below. Note: You only need a DocuSign account to SEND documents, 
      // signing is always free and signers do not need an account. 
      string username = "[EMAIL]"; 
      string password = "[PASSWORD]"; 

      // Enter recipient (signer) name and email address 
      string recipientName = "[RECIPIENT_NAME]"; 
      string recipientEmail = "[RECIPIENT_EMAIL]"; 

      // the document (file) we want signed 
      const string SignTest1File = @"[PATH/TO/DOCUMENT/TEST.PDF]"; 

      // instantiate api client with appropriate environment (for production change to www.docusign.net/restapi) 
      configureApiClient("https://demo.docusign.net/restapi"); 

      //=========================================================== 
      // Step 1: Login() 
      //=========================================================== 

      // call the Login() API which sets the user's baseUrl and returns their accountId 
      string accountId = loginApi(username, password); 

      //=========================================================== 
      // Step 2: Signature Request (AKA create & send Envelope) 
      //=========================================================== 

      // Read a file from disk to use as a document. 
      byte[] fileBytes = File.ReadAllBytes(SignTest1File); 

      EnvelopeDefinition envDef = new EnvelopeDefinition(); 
      envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc"; 

      // Add a document to the envelope 
      Document doc = new Document(); 
      doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes); 
      doc.Name = "TestFile.pdf"; 
      doc.DocumentId = "1"; 

      envDef.Documents = new List<Document>(); 
      envDef.Documents.Add(doc); 

      // Add a recipient to sign the documeent 
      Signer signer = new Signer(); 
      signer.Email = recipientEmail; 
      signer.Name = recipientName; 
      signer.RecipientId = "1"; 

      // Create a |SignHere| tab somewhere on the document for the recipient to sign 
      signer.Tabs = new Tabs(); 
      signer.Tabs.SignHereTabs = new List<SignHere>(); 
      SignHere signHere = new SignHere(); 
      signHere.DocumentId = "1"; 
      signHere.PageNumber = "1"; 
      signHere.RecipientId = "1"; 
      signHere.XPosition = "100"; 
      signHere.YPosition = "100"; 
      signer.Tabs.SignHereTabs.Add(signHere); 

      envDef.Recipients = new Recipients(); 
      envDef.Recipients.Signers = new List<Signer>(); 
      envDef.Recipients.Signers.Add(signer); 

      // set envelope status to "sent" to immediately send the signature request 
      envDef.Status = "sent"; 

      // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests) 
      EnvelopesApi envelopesApi = new EnvelopesApi(); 
      EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef); 

      // print the JSON response 
      Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary)); 

      // *** I added a code here *** 
      Tabs tabs = envelopesApi.ListTabs(accountId, envelopeSummary.EnvelopeId, "1"); 
      // *** I added a code here *** 

      return envelopeSummary; 

     } // end requestSignatureTest() 

     //********************************************************************************************************************** 
     //********************************************************************************************************************** 
     //* HELPER FUNCTIONS 
     //********************************************************************************************************************** 
     //********************************************************************************************************************** 
     public void configureApiClient(string basePath) 
     { 
      // instantiate a new api client 
      ApiClient apiClient = new ApiClient(basePath); 

      // set client in global config so we don't need to pass it to each API object. 
      Configuration.Default.ApiClient = apiClient; 
     } 

     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
     public string loginApi(string usr, string pwd) 
     { 
      // we set the api client in global config when we configured the client 
      ApiClient apiClient = Configuration.Default.ApiClient; 
      string authHeader = "{\"Username\":\"" + usr + "\", \"Password\":\"" + pwd + "\", \"IntegratorKey\":\"" + INTEGRATOR_KEY + "\"}"; 
      Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader); 

      // we will retrieve this from the login() results 
      string accountId = null; 

      // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object 
      AuthenticationApi authApi = new AuthenticationApi(); 
      LoginInformation loginInfo = authApi.Login(); 

      // find the default account for this user 
      foreach (LoginAccount loginAcct in loginInfo.LoginAccounts) 
      { 
       if (loginAcct.IsDefault == "true") 
       { 
        accountId = loginAcct.AccountId; 
        break; 
       } 
      } 
      if (accountId == null) 
      { // if no default found set to first account 
       accountId = loginInfo.LoginAccounts[0].AccountId; 
      } 
      return accountId; 
     } 

    } // end class 
} // end namespace 
Verwandte Themen