2017-03-08 40 views
0

我在DocuSign帳戶中有2個共享模板。我想檢索共享模板列表。我正在做下面的ajax調用。如何檢索DocuSign共享模板列表

我收到一個200狀態調用,所以調用成功,但DocuSign返回HTML而不是JSON。

var DSTemplateURL = localStorage.getItem("ls_DSurl") + "/v2/accounts/" + localStorage.getItem("ls_DS_accountid") + "/templates?"; 
var DSData = 'folder=Shared Templates'; 

request = $.ajax({ 
    headers: { 'Authorization': 'Bearer ' + localStorage.getItem('ls_DSaccess_token') }, 
    type: 'GET', 
    url: DSTemplateURL, 
    data: DSData, 
    //dataType: 'json', 
    contentType: "application/json", 
    cache: false 
}); 
+0

我使用的是錯誤的URL。這是錯誤的ajax代碼: – salemanager

+0

我使用的是{base uri}/v2/accounts/{accountId} /模板,而不是{base uri}/restapi/v2/accounts/{accountId}/templates。上述代碼在使用正確的URL時有效。 – salemanager

回答

1

通過user_filter查詢字符串參數。

GET /v2/accounts/{accountId}/templates?user_filter=shared_with_me 

以下是user_filter參數的可能值。

  • owned_by_me:只顯示用戶擁有的模板。
  • shared_with_me:只顯示與用戶共享的模板。
  • 全部:顯示用戶擁有或共享的所有模板。

如下

var DSTemplateURL = localStorage.getItem("ls_DSurl") + "/v2/accounts/" + localStorage.getItem("ls_DS_accountid") + "/templates?user_filter=shared_with_me"; 

request = $.ajax({ 
    headers: { 'Authorization': 'Bearer ' + localStorage.getItem('ls_DSaccess_token') }, 
    type: 'GET', 
    url: DSTemplateURL, 
    //dataType: 'json', 
    contentType: "application/json", 
    cache: false 
}); 
-1

我回答我自己的問題更改代碼。參考上面的評論。

+0

謝謝你展示過濾器選項。 – salemanager