salemanager
salemanager

Reputation: 19

How do I retrieve a list of DocuSign shared templates

I have 2 shared templates in my DocuSign account. I want to retrieve a list of shared templates. I'm making the below ajax call.

I'm receiving a 200 status call so the call is successful but DocuSign is returning HTML not 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
});

Upvotes: 0

Views: 105

Answers (1)

Praveen Reddy
Praveen Reddy

Reputation: 7383

Pass the user_filter query string parameter.

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

Here are the possible values for the user_filter parameter.

  • owned_by_me: only shows templates the user owns.
  • shared_with_me: only shows templates that are shared with the user.
  • all: shows all templates owned or shared with the user.

Change your code as follows

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

Upvotes: 2

Related Questions