Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2024-11-01 03:00 PM
Hi,
I'm trying to retrieve all deleted record using the API call as documented in this link.
This works in the browser successfully.
But when I try to access the same API from the C# code, it fails with "StatusCode: Unauthorized" as seen in the attached image below the code.
This new API is not included in the Archer Toolbox for testing.
Thank you
public HttpResponseMessage GetDeletedContent_REST(string sessionToken, string baseURL)
{
string uri = baseURL + "api/V2/DeletedContent";
IDictionary<string, string> headers = new Dictionary<string, string>
{
{ "Authorization", "Archer session-id=\"sessionToken\"" },
{ "Method", "GET" }
};
HttpResponseMessage response = CallGetREST(uri, headers);
}
protected HttpResponseMessage CallGetREST(string uri, IDictionary<string, string> headers)
{
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
HttpClient client = new HttpClient();
foreach (KeyValuePair<string, string> header in headers)
{
client.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value);
}
HttpResponseMessage response = client.GetAsync(uri).Result;
return response;
}
2024-11-01 03:19 PM
@Archerwizz2022 is the user that you are using in your code assigned to this role?
Advisory Consultant
2024-11-01 03:19 PM
@Archerwizz2022 is the user that you are using in your code assigned to this role?
Advisory Consultant
2024-11-01 03:32 PM
Thank you and appreciate your prompt response.
You are right. I was using the regular API account, not the one I created and assigned "Deleted Record Auditor" role.
Thanks again.