08-02-2021 02:37 AM
Hello,
I am new to Snap logic, I am trying to create a pipeline where I need to pass the json input request payload. based on the input I have to check for condition and then route to TWO different REST GET calls.
my input json is like this
{
“state”: “sample_state”,
“count”: “sample_count”,
“Caller”: “sample_caller”,
“fromDate”: “sample_fromdate”,
“toDate”: “sample_todate”,
“SysId”: “sample_sysid”
}
how to pass this from external app. And how to read the values to pass to REST GET call.
Answer will help a lot. Thanks
08-09-2021 02:50 AM
@viktor_n thanks for the reply it worked after using JSON Formater.
Now I am trying to map the json fields in the output to different name which backend code is expecting
The input json
{
"result": [
{
"number": {
"display_value": "INC0029337",
"value": "INC0029337"
},
"short_description": {
"display_value": "test",
"value": "test"
},
"sys_id": {
"display_value": "90a4a74e1be97010ef9f6208b04bcb96",
"value": "90a4a74e1be97010ef9f6208b04bcb96"
},
"comments": {
"display_value": "thh lafldsf. legmsfd",
"value": ""
},
"state": {
"display_value": "In Progress",
"value": "2"
},
"sys_updated_on": {
"display_value": "2021-07-26 16:23:28",
"value": "2021-07-26 10:53:28"
}
},
{
"number": {
"display_value": "INC0029336",
"value": "INC0029336"
},
Here I need to map number.value → ticketNumber
short_description.display_value → description
sys_id.value → sys_id
comments.display_value → comments
state.display_value → status
sys_updated_on.value → lastUpdateTime
the final result array looks like
after re-map
{
"result": [
{
"ticketNumber": "INC0029337",
"description": "test",
"sys_id": "90a4a74e1be97010ef9f6208b04bcb96",
"comments": "hello",
"status": "In Progress", ,
"lastUpdateTime": "2021-07-26 16:23:28"
},
{
"ticketNumber": "INC0029337",
"description": "test",
"sys_id": "90a4a74e1be97010ef9f6208b04bcb96",
"comments": "hello",
"status": "In Progress", ,
"lastUpdateTime": "2021-07-26 16:23:28"
},
Mapping like this becoming very difficult. There is no Json one to one mapping. Can you pls suggest mapping logic.
thanks
arun
08-09-2021 03:20 AM
Hi @arunnp ,
This can be done with the following steps:
Add JSON Splitter after the input json and split on $result
Add a mapper to map the corresponding values ( you can easily map the values now since they are no longer in an array )
And finally add a Group by N snap to group every object into a single array.
Result:
{
"result": [
{
"ticketNumber": "INC0029337",
"description": "test",
"sys_id": "90a4a74e1be97010ef9f6208b04bcb96",
"comments": "thh lafldsf. legmsfd",
"status": "In Progress",
"lastUpdateTime": "2021-07-26 10:53:28"
},
{
"ticketNumber": "INC0029337",
"description": "test",
"sys_id": "90a4a74e1be97010ef9f6208b04bcb96",
"comments": "thh lafldsf. legmsfd",
"status": "In Progress",
"lastUpdateTime": "2021-07-26 10:53:28"
}
]
}
]
08-09-2021 04:25 AM
@j.angelevski it worked thanks a lot