I'm trying to export all users list using DocuSign admin API, however I have provide the required consent but still getting "Unauthorized error"
Below is the code (Azure Function C#) that i am using:
string url = $"https://api.docusign.net/Management/v2/organizations/ORGID/exports/user_list";
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var requestBody = new StringContent("{\"type\": \"organization_user_list_export\"}", Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync(url, requestBody);
if (response.IsSuccessStatusCode)
Error: {StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:{ Cache-Control: no-cache Pragma: no-cache X-DocuSign-TraceToken: XXXXXXXXXXXXXXXX602 X-DocuSign-Node: SE101FE98 Date: Sat, 15 Feb 2025 20:15:28 GMT Strict-Transport-Security: max-age=31536000; includeSubDomains Content-Type: application/json; charset=utf-8 Expires: -1 Content-Length: 87}}
CONSENT URL USED https://account-d.docusign.com//oauth/auth?response_type=code&scope=user_read user_write organization_read organization_write account_read group_read permission_read identity_provider_read domain_read&client_id=CLIENT_ID&redirect_uri=http://localhost
The consent URL is from the developer environment. The API URL is from production.
If you want to use developer environment, you have to change the API URL basePath to
https://api-d.docusign.net/Management/v2
If you want to use production (assuming your app is live in prod) then the consent URL should be changed to:
https://account.docusign.com//oauth/auth?response_type=code&scope=user_read user_write organization_read organization_write account_read group_read permission_read identity_provider_read domain_read&client_id=CLIENT_ID&redirect_uri=http://localhost