05/26/2022 03:01 AM
We are connecting to the target system where default payload needs to be sent in update transaction.
Payload has a mandatory attribute which we don't want to update in update transaction.
So we thought to make a get call (call1) and then make a update call (call2) mapping response of get call for mandatory attribute.
Response of Call1 has array type attribute. So can we map complete array as is from response to mandatory attribute ?
Below is the response of get call containing mandatory attribute array :
"Credentials": [
{
"CardNumber": "15798",
"EndDate": "2022-12-21T23:59:59",
"Pin": "8135",
"ProfileId": 1
},
{
"CardNumber": "297",
"EndDate": "2022-12-21T23:59:59",
"Pin": "0",
"ProfileId": 11
}
],
Below is how mapping done in UpdateAccountJSON
\"Credentials\":${response.call1.message.Credentials[]?:''},
However this is failing, Any suggestion ??
05/26/2022 10:02 PM
You may want to try to pass the value in the following way:
\"Credentials\":\"${response?.call1?.message?.Credentials?.size() > 0 ? response?.call1?.message?.Credentials : ''}\",
or
\"Credentials\":\"${response?.call1?.message?.Credentials?.length > 0 ? response?.call1?.message?.Credentials : ''}\",
01/25/2023 07:20 AM
how can we parse such response in REST connector? folloing is full response, nothing is missing in it
[
{
"key": "APPLICATION_NAME",
"value": "Gitlab"
},
{
"key": "GROUP_CATEGORY",
"value": "CTB"
},
{
"key": "GROUP_PRIMARY_OWNER",
"value": "Test1"
},
{
"key": "GROUP_SECONDARY_OWNER",
"value": "Test2"
}
]
06/02/2022 12:26 AM
@amit_krishnajit Thank you for your response!
Array can not be passed in the double quotes ("" ), And seems without double quotes value not fetching from the response.
06/02/2022 12:43 AM
Can you please share the httpParams from the logs when you pass the array without the double quotes?
You may enable extra logs in REST Connector by configuring Config JSON in the following way:
{ "showLogs":true}
06/02/2022 03:08 AM
01/25/2023 12:48 PM
You can pass some portion of code inside REST API Calls when getting a response that looks like array or map.
Example : Let's say you have a list of objects as response from your GET API Call, you might be able to use the following :
${for (Map map : response.call1.message) {<INSERT LOGIC>}}
Where "call1" is your GET API Call name, message contains your list of objects, and you want to iterate over the list.