I am trying to create and then immediately deactivate an OKTA application using a c# code with the OKTA API.
I am able to successfully create the application and extract the client id, but when trying to deactivate the app, I get an error that the client was not found.
This is how I try to deactivate:
public async static Task<bool> DeactivateApp(string accessToken, string clientId)
{
string oktaDomain = "https://myDomain.okta.com";
string requestUrl = $"{oktaDomain}/api/v1/apps/${clientId}/lifecycle/deactivate";
var httpClient = new HttpClient();
string token = $"Bearer {accessToken}";
httpClient.DefaultRequestHeaders.Add("Authorization", token);
var response = await httpClient.PostAsync(requestUrl, null); //here i get the 404 response
...
}
The client id is correct and I can see that an app does exist with that client id.
What could be the cause of that error?
So the problem was with the url.
string requestUrl = $"{oktaDomain}/api/v1/apps/${clientId}/lifecycle/deactivate";
I accidentally added $ before the clientId
in the middle thus creating a wrong url. It searched an id with a $ at the start which of course didn't exist. Once removed, it worked as it should