cancel
Showing results for 
Search instead for 
Did you mean: 

Pass the json input request payload to REST GET

arunnp
New Contributor II

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

12 REPLIES 12

arunnp
New Contributor II

@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

j_angelevski
Contributor III

Hi @arunnp ,

This can be done with the following steps:
image

  1. Add JSON Splitter after the input json and split on $result
    image

  2. Add a mapper to map the corresponding values ( you can easily map the values now since they are no longer in an array )
    image

  3. And finally add a Group by N snap to group every object into a single array.
    image

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"
      }
    ]
  }
]

arunnp
New Contributor II

@j.angelevski it worked thanks a lot