This is tricky to solve since no data is returned. Unfortunately, if no other endpoints to fetch/filter users is available, you may need to wait until next aggregation for the data to resolve.
If you have an API endpoint available that allows for finding the account off of a filter with an account attribute that you know (ex. /accounts?filter=name eq ‘’), you could use an After Operation rule to query off of the known information and fetch the generated account ID. For example:
Use restClient.executeGet() for the filterable endpoint using the requestEndPoint.getBody() information that was sent on the create request.
Return an updated map with the account information that you are able to fetch.
For information on the Java calls to use within the rule check out this.
In theory, you can do this After Operation rule to mock a response object with the requested information even if you don’t have the filter endpoint, but you wouldn’t have the account ID until next aggregation.
Is there a filterable endpoint that could work for you? If you give this a go, let me know how it works for you
Hi @denanife,
Couple of things before you can go to AfterOperationRule.
What does your create API return as a response. Does it give you any id which belongs to the account that is created. If yes first you need to map that as resMappingObj in create operation
Once you have the response you can take that value in WebServiceAfterOperationRule and do something like this.
String idFromResponse = null;
for (Map iterateMap : processedResponseObject) {
log.info("id ::" + iterateMap.get("id"));
if(iterateMap != null && iterateMap.get("id") != null) {
idFromResponse = (String) iterateMap.get("id");
log.info("id that is created after the account creation::" + idFromResponse);
}
}
You can use the above id to make get call and prepare updatedMapInfo.
Something along the lines of this should is what I was talking about:
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.text.ParseException;
Map updatedMapInfo = new HashMap();
List finalList = new ArrayList();
Map body = requestEndPoint.getBody();
String jsonBody = (String) body.get("jsonBody");
Map jsonMap = JsonUtil.toMap(jsonBody);
if (jsonMap != null) {
for (int i = 0; i < processedResponseObject.size(); i++) {
Map responseMap = (Map) processedResponseObject.get(i);
// Get Login from requestEndpoint
String login = (String) jsonMap.get("login");
// Get ID
List allowedStatuses = requestEndPoint.getResponseCode();
Map header = requestEndPoint.getHeader();
String fullUrl = requestEndPoint.getFullUrl(); // Can change the URL to what the filter is.
String createdAccountFiltered = restClient.executeGet(fullUrl + "?login=" + login, header, allowedStatuses);
Map createdAccountMap = JsonUtil.toMap(createdAccountFiltered);
String accountId = createdAccountMap.get("id");
// Add info to response
responseMap.put("id", accountId);
responseMap.put("login", login);
responseMap.put("<some-attribute>", jsonMap.get("<some-attribute>"));
finalList.add(responseMap);
}
updatedMapInfo.put("data", finalList);
}
return updatedMapInfo;
Don’t forget to add try/catch for exceptions and to add additional logging for debugging. You can catch the log statements by turning on CCG debug logging for the connector and viewing the ccg.log file on the VA.
I forgot to mention in my previous post, but ensure that you add the response mapping configuration to the operation in the UI for this to work correctly.