Delete a user from jira cloud returns 401

Hi everyone,
I’ve been trying to delete jira users using the requestJira but i got 401 response. Here is my code

resolver.define('delete-users', async (req) => {
  const { user } = req.payload;
    try {
      const response = await api
        .asUser()
        .requestJira(route`/rest/api/3/user?accountId=${user}`, {
          method: 'DELETE',
        });
      if (response.status == 204) {
        return { status: 'ok' };
      } else if (response.status == 401) {
        return { status: 'Unauthorized' };
      } else if (response.status == 403) {
        return { status: 'Forbidden' };
      } else if (response.status == 404) {
        return { status: 'Not found' };
      } else {
        return { status: 'Error' };
      }
    } catch (error) {
      console.error(`Failed to delete user ${user}:`, error);
      return null; // Handle failure scenario
    }
  });

i first followed the docs and used api.requestJira() without asUser() but it did not work, then tried with asUser() but it did not work either, although when i tested it with postman it returned a 204 response.

Sorry everyone, actually This API resource doesn’t support Oauth2.

1 Like