At times, $response.CostCenter$ is not resolved (token appears literal or empty), the child call executes, and the child response body is empty (no records), even though the same URL works when tested manually.
Questions:
Is parent $response data guaranteed to be available in a child call’s BeforeOperation rule?
If not, what’s the supported way to pass the parent value into the child request (e.g., staged variable, connectorStateMap, different rule stage)?
Is requestEndPoint.setFullUrl(...) the correct approach at this stage, or should we prefer setContextUrl(...) for child calls?
Is parent $response data guaranteed to be available in a child call’s BeforeOperation rule? I don’t think that’s possible.
If not, what’s the supported way to pass the parent value into the child request (e.g., staged variable, connectorStateMap, different rule stage)? My suggestion would be using connectorStateMap.
Is requestEndPoint.setFullUrl(...) the correct approach at this stage, or should we prefer setContextUrl(...) for child calls?
It depends, How you want to handle. In general, setContextUrl - Sets the context URL for the particular operation (Create User, Update User, Account Aggregation, etc.).e.g. - /request/getAccount setFullUrl - Sets the complete URL (endpoint ) of the operation that need to be performed for the particular operation (Create User, Update User, Account Aggregation, etc.).e.g. https://example.com/request/getAccount
You could try something like setting $response.costCenter$ in the Context URL of the child operation (in the UI). Since this is getting populated by the parent endpoint, you can then use requestEndPoint.getContextUrl() to get this value from the context URL into the rule, transform it accordingly in the rule, then either set the contextUrl using request.setContextUrl(), if the full URL should be the baseUrl defined this this value at the end, or construct the full URL using request.getBaseUrl() + transformed contextUrl/costCenter value + whatever else needs to be in the full URL and set it with request.setFullUrl(). If $response.costCenter$ is sometimes not populated by the parent operation’s response data for whatever reason, you can have the rule handle this by checking for a null value and handling it accordingly: setting a default value, throwing a specific error, trying to get the value some other way (such as using executeGet() to make another call), etc.
I have tried the similar setup in the past to use the parent child endpoint configuration to get make subsequent api calls based on the response receieved in the parent call, but unfortunately it did not help.
It was mainly due to the fact that the response received in the parent endpoint, I could not read it in the child rule thus it did not work out.
In your case although you just need to change the context url as I understood so may be the suggestion from Zach might help but setting the child context URL as $response.costCenter.
Although to share how i solved my issue was by not using parent child endpoint configuration. I used just one endpoint and used a after operation rule where once i have the response from the aggregation i will use the java logic to iterate though the costcenter values received.
Once the I have the costcenter values, i would then create a restClient and make an additonal API call using the rule itself and then based on the result from costcenter endpoint I will add it to the main response.