2016-12-14 68 views
1

嗨,有人可以請幫助here.Bowow是請求和錯誤: 錯誤 「指定的集成商密鑰未找到或被禁用。未指定集成商密鑰。」 JSON請求:指定的集成商密鑰未找到或被禁用。沒有指定集成密鑰

var creds = JSON.stringify({ 
Username: "[email protected]", 
Password: "winter18", 
IntegratorKey: "a51e3ce6-4ea9-4f3d-9287-6cebe8231849" 
}); 
var pObj = new Object(); 
var cObj = new Object(); 
cObj.documentBase64 = "WzEwLzYvMTU"; 
cObj.documentId = "1234"; 
cObj.fileExtension = ".xml"; 
cObj.name = "SUresh"; 
cObj.order= "qeqeqeq"; 
pObj.documents = cObj; 
pObj.emailSubject ="Suresh"; 
       $.ajax({ 

        url: 'https://demo.docusign.net/restapi/v2/accounts/2071095/envelopes', 
        beforeSend: function (request) 
        { 
         /*ApiClient apiClient = new ApiClient("https://apiexplorer.docusign.com"); 
         Configuration cfi = new Configuration(apiClient); 
         cfi.AddDefaultHeader("X-DocuSign-Authentication", creds); 
         AuthenticationApi authApi = new AuthenticationApi(cfi);*/ 
         request.setRequestHeader("Accept", "application/json"); 
         request.setRequestHeader("Accept-Encoding","gzip,deflate,sdch"); 
         request.setRequestHeader("Accept-Language","en-US,en;q=0.8,fa;q=0.6,sv;q=0.4"); 
         request.setRequestHeader("Origin","https://apiexplorer.docusign.com"); 
         request.setRequestHeader("Referer","https://apiexplorer.docusign.com/"); 
         request.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"); 
         request.setRequestHeader("Authorization", "bearer 29Diokb4VuiEA/W/F/FTyywW1f4="); 
         request.setRequestHeader("Content-Type", "application/json"); 
         request.setRequestHeader("X-DocuSign-Authentication", creds); 

        }, 
        method: 'POST', 
        dataType: 'jsonp', 
        crossDomain: true, 
        data: JSON.stringify(pObj), 
        success: function(msg){ 
         console.log('success: '+msg); 
        }, 
        error: function(msg){ 
          //console.log(msg); 
        } 
        }); 

回答

0
  • 爲 「X-的DocuSign的驗證」 A樣品的鍵/值的例子是如下所示:

    「X-的DocuSign的驗證」:{ 「用戶名」: 「[email protected]」, 「密碼」: 「pwdhere」, 「IntegratorKey」: 「刪除」}

請確保該格式與適當的雙引號匹配。

  • 請注意,您需要獲取新的集成密鑰。 IK不應該公開分享。
1

您的代碼

var creds = JSON.stringify({ 
    Username: "[email protected]", 
    Password: "winter18", 
    IntegratorKey: "a51e3ce6-4ea9-4f3d-9287-6cebe8231849" 
}); 

... 

request.setRequestHeader("X-DocuSign-Authentication", creds); 

看起來不錯。

但你通過同時送OAuth認證證書:

request.setRequestHeader("Authorization", "bearer 29Diokb4VuiEA/W/F/FTyywW1f4="); 

這就是問題所在。要麼使用X-DocuSign-Authentication進行身份驗證,要麼使用Authorization進行OAuth身份驗證,但不能同時使用兩者。

新增

而且,不需要這些標題:

request.setRequestHeader("Origin","https://apiexplorer.docusign.com"); 
request.setRequestHeader("Referer","https://apiexplorer.docusign.com/"); 
request.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"); 

而且我不知道你爲什麼要添加這些:

request.setRequestHeader("Accept-Encoding","gzip,deflate,sdch"); 
request.setRequestHeader("Accept-Language","en-US,en;q=0.8,fa;q=0.6,sv;q=0.4");