Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..

cancel
Showing results for 
Search instead for 
Did you mean: 

New deletedcontent API not working

Archerwizz2022
Contributor III

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

 

Archerwizz2022_0-1730487527103.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

DavidPetty
Archer Employee
Archer Employee

@Archerwizz2022 is the user that you are using in your code assigned to this role?

DavidPetty_0-1730488749464.png

 

 Advisory Consultant

View solution in original post

2 REPLIES 2

DavidPetty
Archer Employee
Archer Employee

@Archerwizz2022 is the user that you are using in your code assigned to this role?

DavidPetty_0-1730488749464.png

 

 Advisory Consultant

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.