Check for username in OKTA before creating one in Active directory

Hello,
Developing the application,that check for the Username in OKTA before creating one in Active directory.
Can I know the java webservice that be used to check for username in OKTA and provide the real time results.

Thanks in Advance,
Sindhu

Hi @Sindhu

You can do a search on the Okta org using filter and see if there is a response (user exists) or empty response (user doesn’t exist).

Here is an example in Java using OkHttpClient

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://org.okta.com/api/v1/users?filter=profile.login%20eq%20%22user@domain.com%22")
  .get()
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "SSWS API_TOKEN_HERE")
  .build();

Response response = client.newCall(request).execute();