Can we change the Operation type in Webservices connector using requestEndPoint.setOperationType("DELETE")

We have a use case where the when all the entitlements are removed from a user, the account needs to be deleted at the target application. There is an API available with operation = DELETE which works perfect when used under “Delete Account” operation.

However, we need to call the same API from “Remove Entitlement” operation when all current entitlements are marked to be removed.

  • What have you tried?
    If list of entitlements being removed match the list of current list of entitlements, then update using the below line
    `requestEndPoint.setOperationType("DELETE");`

  • What errors did you face (share screenshots)?
    No effect. DELETE API was not called

  • Share the details of your efforts (code / search query, workflow json etc.)?

if (roleIds.isEmpty()) requestEndPoint.setOperationType("DELETE");
else updateRolesOfUser(nativeId, roleIds);

Hi,

You can change the operation to delete in before provisioning rule.

-Abhinov

Hi @nithesh-hearst,

Good question! I can see what you’re trying to achieve.

Perhaps requestEndPoint.setOperationType(“DELETE”) won’t change the HTTP operation. From the java doc it seems setOperationType method sets the logical operation type but curious how it can take effect in the connector. Would you mind logging the operation and sharing: -

// Log the initial operation type 
log.info("Initial operation type: " + requestEndPoint.getOperationType()); log.info("HTTP method type: " + requestEndPoint.getHttpMethodType());

setHttpMethodType looks promising but you may use executeDelete to call the endpoint instead: -

if (roleIds.isEmpty()) {
    // Define URL, header and allowed statuses separately if need be.
    Map header = requestEndPoint.getHeader();
    List allowedStatuses = new ArrayList();
    allowedStatuses.add( "2**" );
    String baseUrl = application.getAttributeValue("genericWebServiceBaseUrl")
    String url = baseUrl + "/api/Users" + nativeId
    String response = restClient.executeDelete(url, header, allowedStatuses);
}

You could let the remove entitlement operation complete and perform this logic in a WebServicesAfterOperation rule as well. You might still need to return a dummy account, preferably disabled as the actual operation would have been modfiy in the provisioningPlan.

Good luck!

Thanks @TheOneAMSheriff `setHttpMethodType` did the trick.

1 Like

Hi @nithesh-hearst,

Thank you for letting me know, I am glad you got it working. Did you had to return the account after the delete operation?

1 Like

As I changed the HTTP method, it did not return any error because it was not trying to get the user anymore

1 Like