Now issue is we have user_id in request and response
Page 1 / 1
Are you asking about how this response should be defined in your swagger.json file? You can try using https://restunited.com/ which will allow you to input an example response and then it will attempt to create what the definition may look like for this response in swagger format.
All records from retention_candidates and deactivation_candidates.
I want them as two variables
Given the current JSON structure, it is not possible to deserialize both deactivation_candidates and retention_candidates arrays in a single method within the K2 REST Service Broker framework. This limitation exists because each of these arrays can contain a different number of items, making it impractical for K2 to map them into a single SmartObject structure automatically in one call.
The recommended approach is to implement two separate deserialization methods—one for deactivation_candidates and one for retention_candidates. If the main API call is configured as a Read method, you can create a composite SmartObject that utilizes the Deserialize Array method in secondary calls. This allows you to retrieve each set of candidate properties separately.
Please note that the deserialization itself will be executed only once. The consideration here is that the full JSON response will be returned as a property for each deserialized item, which can increase the overall size of the response, especially if the payload is large.
Recommended approach: If possible, consider adjusting the API design to expose two separate endpoints—one for deactivation_candidates and one for retention_candidates, each returning an array at the root level. This approach allows for more efficient integration, leveraging Swagger definitions so that K2 can map internal properties automatically.
If modifying the API is not an option, you could implement a custom Service Broker (for On-Prem environments) or a JavaScript Service Provider (JSSP) (for K2 Cloud and latest On-Prem version) to handle deserialization. However, even with custom solutions, combining both arrays in a single deserialization call remains impractical due to their differing lengths.