2016-04-12 10 views
1

Ich versuche, den folgenden Code as mentioned here,DocuSign Der angegebene Integrator Key wurde nicht gefunden oder deaktiviert

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; 
} 

Es funktioniert nicht, ich habe es mit einem Try-Catch gewickelt und diesen Fehler bemerkt,

Error calling Login: { 

"errorCode": "PARTNER_AUTHENTICATION_FAILED", 

"message": "The specified Integrator Key was not found or is disabled." 

} 

Als ich an dem Fiedler aussehen,

enter image description here

Die Anfrage geht an www.docusign.net, wo ich sie an https://demo.docusign.net senden möchte. Wie kann ich den Base Uri für diesen Code ändern?

Antwort

5

Ok, herausgefunden, das Problem. Fehlermeldung ist irreführend.

Schritt 1 - Scheint so, als müsste ich das Konfigurationsobjekt erstellen.

ApiClient client = new ApiClient(basePath: "https://demo.docusign.net/restapi"); 
      Configuration cfg = new Configuration(client); 

Schritt 2 - Notwendigkeit, den Auth-Header

cfg.AddDefaultHeader("X-DocuSign-Authentication", authHeader); 

Schritt 3 Pass es auf den Konstruktor von Api

AuthenticationApi authApi = new AuthenticationApi(cfg); 
+0

Ich hatte ein Authentifizierungsproblem selbst in der inoffiziellen .NET präsentieren zu setzen Nur Core NuGet-Paket; Die Instanziierung einer neuen Konfigurationsinstanz, wie Sie sie hervorgehoben haben, scheint sie jedoch gelöst zu haben. Danke: D – ne1410s

Verwandte Themen