@Override public Object create(String type, ApiRequest request, ResourceManager next) { String ip = request.getClientIp(); Agent agent = request.proxyRequestObject(Agent.class); /* * This ensures that the accountId is always set from the request and * never overwritten by the default accountId setting logic. In the * situation in which the client doesn't have access to the accountId * field, the result will be null, which is correct. You want it to be * null so that the AgentCreate logic will create an account for this * Agent */ agent.setAccountId(agent.getAccountId()); String uri = agent.getUri(); String user = DataUtils.getFieldFromRequest(request, AgentConstants.USER, String.class); if (uri == null) { uri = getUri(user, ip); if (uri != null) { isUnique(uri); agent.setUri(uri); } } return super.create(type, request, next); }