38
Views
39
Comments
Solved
how to pass the request in the form of text in API
Question

hi team 

i have an one doubt how we can pass the request in the form of text format actually the request i have in form of json.

and then it will return the response that response also i have for your reference i can share here.

now my doubt is how we can pass the json value as text for API while hitting in postman i am getting the error as

{

    "Errors": [

        "Failed to deserialize JSON to CustomziedResponse:\nUnexpected character encountered while parsing value: s. Path '', line 0, position 0."

    ],

    "StatusCode": 500

}


for your reference i have attached the oml and request and response. we need to pass the request as text format and it will return the response here we only make the response please help me to fix this.

Request

{

  "status": "SUCCESS",

  "message": "All Good!",

  "data": {

    "7": {

      "name": "Congruent",

      "role_id": 1,

      "role_name": "superuser",

      "children": {

        "45": {

          "name": "125 EMS Hotel LLC",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "48": {

          "name": "24 Hour Fitness USA",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "49": {

          "name": "250 East Ponce Owner",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "50": {

          "name": "3PLAi",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "51": {

          "name": "4_WHEEL_AUTO_PARTS",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "52": {

          "name": "50_East_Chestnut_Condos",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "53": {

          "name": "Acton_Academy",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "54": {

          "name": "ADVANTAGE_TERMITE",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "55": {

          "name": "Aegis_Living",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "56": {

          "name": "AG-ARA_TOWN_CENTER",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "57": {

          "name": "Aimbridge_Hospitality",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "58": {

          "name": "AIMCO",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "59": {

          "name": "AJAPPJR",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "60": {

          "name": "ALH_Med_Center",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "61": {

          "name": "ALH_West_Loop",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "62": {

          "name": "ALMC_Suwanee",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "63": {

          "name": "Ancon_Marine",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "64": {

          "name": "For_Eyes_Optical",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "140": {

          "name": "TEST",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        }

      }

    },

    "8": {

      "name": "Global",

      "role_id": 1,

      "role_name": "superuser",

      "children": {

        "45": {

          "name": "125 EMS Hotel LLC",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "48": {

          "name": "24 Hour Fitness USA",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        },

        "49": {

          "name": "250 East Ponce Owner",

          "role_id": 1,

          "role_name": "superuser",

          "children": {}

        }

      }

    }

  }

}

 


Response

{

  "status": "SUCCESS",

  "message": "All Good!",

  "data": {

    "ParentList": [

      {

        "ParentID": 7,

        "name": "Congruent",

        "role_id": 1,

        "role_name": "superuser",

        "Children": [

          {

            "collection": {

              "collectionID": 45,

              "name": "125 EMS Hotel LLC",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 48,

              "name": "24 Hour Fitness USA",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 49,

              "name": "250 East Ponce Owner",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 50,

              "name": "3PLAi",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 51,

              "name": "4_WHEEL_AUTO_PARTS",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 52,

              "name": "50_East_Chestnut_Condos",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 53,

              "name": "Acton_Academy",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 54,

              "name": "ADVANTAGE_TERMITE",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 55,

              "name": "Aegis_Living",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 56,

              "name": "AG-ARA_TOWN_CENTER",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 57,

              "name": "Aimbridge_Hospitality",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 58,

              "name": "AIMCO",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 59,

              "name": "AJAPPJR",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 60,

              "name": "ALH_Med_Center",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 61,

              "name": "ALH_West_Loop",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 62,

              "name": "ALMC_Suwanee",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 63,

              "name": "Ancon_Marine",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 64,

              "name": "For_Eyes_Optical",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 140,

              "name": "TEST",

              "role_id": 1,

              "role_name": "superuser"

            }

          }

        ]

      },

      {

        "ParentID": 8,

        "name": "Global",

        "role_id": 1,

        "role_name": "superuser",

        "Children": [

          {

            "collection": {

              "collectionID": 45,

              "name": "125 EMS Hotel LLC",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 48,

              "name": "24 Hour Fitness USA",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 49,

              "name": "250 East Ponce Owner",

              "role_id": 1,

              "role_name": "superuser"

            }

          }

        ]

      }

    ]

  }

}


thanks and regards

karthick 

SandBox.oml
Solution

Since "Data" only contains a "ParentList", the mapper doesn't show "Data" seperately, but only "Data.ParentList". So you need to assign the ParentList with the same datatype, as you cannot map in a mapping. Since RawResponse is a structure, not a list, you could just put the assign below that, and map if needed:

Note that OutSystems is a strongly-typed language, so you need to specify the conversion (mapping) if you have different data types.


Hi Karthick Balaji,

Kindly share the API details so that i can get the correct scenario you are facing.

this is the request 

"{\"status\":\"SUCCESS\",\"message\":\"AllGood!\",\"data\":{\"7\":{\"name\":\"Congruent\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{\"45\":{\"name\":\"125EMSHotelLLC\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"48\":{\"name\":\"24HourFitnessUSA\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"49\":{\"name\":\"250EastPonceOwner\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"50\":{\"name\":\"3PLAi\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"51\":{\"name\":\"4_WHEEL_AUTO_PARTS\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"52\":{\"name\":\"50_East_Chestnut_Condos\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"53\":{\"name\":\"Acton_Academy\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"54\":{\"name\":\"ADVANTAGE_TERMITE\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"55\":{\"name\":\"Aegis_Living\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"56\":{\"name\":\"AG-ARA_TOWN_CENTER\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"57\":{\"name\":\"Aimbridge_Hospitality\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"58\":{\"name\":\"AIMCO\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"59\":{\"name\":\"AJAPPJR\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"60\":{\"name\":\"ALH_Med_Center\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"61\":{\"name\":\"ALH_West_Loop\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"62\":{\"name\":\"ALMC_Suwanee\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"63\":{\"name\":\"Ancon_Marine\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"64\":{\"name\":\"For_Eyes_Optical\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"140\":{\"name\":\"TEST\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}}}},\"8\":{\"name\":\"Global\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{\"45\":{\"name\":\"125EMSHotelLLC\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"48\":{\"name\":\"24HourFitnessUSA\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"49\":{\"name\":\"250EastPonceOwner\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}}}}}}"




i am getting the error of 

{

    "Errors": [

        "Failed to deserialize JSON to Structure1:\nError converting value \"{\"status\":\"SUCCESS\",\"message\":\"AllGood!\",\"data\":{\"7\":{\"name\":\"Congruent\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{\"45\":{\"name\":\"125EMSHotelLLC\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"48\":{\"name\":\"24HourFitnessUSA\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"49\":{\"name\":\"250EastPonceOwner\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"50\":{\"name\":\"3PLAi\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"51\":{\"name\":\"4_WHEEL_AUTO_PARTS\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"52\":{\"name\":\"50_East_Chestnut_Condos\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"53\":{\"name\":\"Acton_Academy\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"54\":{\"name\":\"ADVANTAGE_TERMITE\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"55\":{\"name\":\"Aegis_Living\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"56\":{\"name\":\"AG-ARA_TOWN_CENTER\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"57\":{\"name\":\"Aimbridge_Hospitality\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"58\":{\"name\":\"AIMCO\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"59\":{\"name\":\"AJAPPJR\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"60\":{\"name\":\"ALH_Med_Center\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"61\":{\"name\":\"ALH_West_Loop\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"62\":{\"name\":\"ALMC_Suwanee\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"63\":{\"name\":\"Ancon_Marine\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"64\":{\"name\":\"For_Eyes_Optical\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"140\":{\"name\":\"TEST\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}}}},\"8\":{\"name\":\"Global\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{\"45\":{\"name\":\"125EMSHotelLLC\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"48\":{\"name\":\"24HourFitnessUSA\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"49\":{\"name\":\"250EastPonceOwner\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}}}}}}\" to type 'ssSandBox.RestRecords.JSONSTStructure1Structure'. Path '', line 1, position 2322."

    ],

    "StatusCode": 500

}

pass the request as JSON instead of text.

this is scenario we need to pass only in text format i am getting the error while de serializing 

Hi 

i added new Structure please use that in deseraialize

SandBox.oml

now i need to de serialize that structure right

i am still get that error only 

{

    "Errors": [

        "Failed to deserialize JSON to Customzied:\nError converting value \"{\"status\":\"SUCCESS\",\"message\":\"AllGood!\",\"data\":{\"7\":{\"name\":\"Congruent\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{\"45\":{\"name\":\"125EMSHotelLLC\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"48\":{\"name\":\"24HourFitnessUSA\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"49\":{\"name\":\"250EastPonceOwner\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"50\":{\"name\":\"3PLAi\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"51\":{\"name\":\"4_WHEEL_AUTO_PARTS\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"52\":{\"name\":\"50_East_Chestnut_Condos\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"53\":{\"name\":\"Acton_Academy\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"54\":{\"name\":\"ADVANTAGE_TERMITE\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"55\":{\"name\":\"Aegis_Living\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"56\":{\"name\":\"AG-ARA_TOWN_CENTER\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"57\":{\"name\":\"Aimbridge_Hospitality\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"58\":{\"name\":\"AIMCO\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"59\":{\"name\":\"AJAPPJR\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"60\":{\"name\":\"ALH_Med_Center\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"61\":{\"name\":\"ALH_West_Loop\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"62\":{\"name\":\"ALMC_Suwanee\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"63\":{\"name\":\"Ancon_Marine\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"64\":{\"name\":\"For_Eyes_Optical\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"140\":{\"name\":\"TEST\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}}}},\"8\":{\"name\":\"Global\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{\"45\":{\"name\":\"125EMSHotelLLC\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"48\":{\"name\":\"24HourFitnessUSA\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}},\"49\":{\"name\":\"250EastPonceOwner\",\"role_id\":1,\"role_name\":\"superuser\",\"children\":{}}}}}}\" to type 'ssSandBox.RestRecords.JSONSTCustomziedStructure'. Path '', line 1, position 2322."

    ],

    "StatusCode": 500

}


could you change the structure here and check

i have changed every where brother but still i am getting failed to de serialized error 

Need to pass request like this not like you passed , and can you rechange to structure back what you created . will test with your structure

that's why i am telling i know if i am passing the request as json i am able to get an response but i am trying to pass the request text/plain this is one kind of approach for request.

no karthik , basically the rest API (post)will support only json, the outsystems dont have any data type called json . so we create a request with the data type of text . we need to build the json structure and passed as text request inside outsystems .

it will not work in postman 

we can do that it is possible but we need to deserialize that.

yes , we can deserialize it inside server action . based on JSON we need to create structure and need to use that structure in deserialize place .

Hope it will work!

Thanks .


i have tried same way only but i am not getting the response

dude it was simple logic . take some breath ,

check your json and structure are match .

Only that error will come when only your deserialize structure not matched with json .

and make sure no keywords in your json like "/n or \" ext

okay we can use string replace it works right

yup , if you cleared please close this thread mark solution

actually the pattern is "\ /" this one right or something else

can you help me to find out actual pattern for this error replace please

Hi Karthick,

If you want to receive Text that contains JSON as Text in an API, all you need to do is define a Text input with Receive In set to Body. OutSystems will then not try to deserialize the JSON received. You'll need to do that yourself afterwards.

Similarly, of you want to send Text that contains JSON, define a Text output with Send In set to Body. You'll need to serialize any data you have yourself before sending.

There's been a lot of back-and-forth in the thread above, and there's a lot that I don't understand why you are doing it, like seemingly sending escaped JSON in Postman, but I might not understand what you're trying to do. If you explain some more your exact use case, I might be able to help better.


Hi kilian

I am trying to do what means, I have an API response okay

first thing is i am passing the one of the API response only i am passing here as a request for my own exposing API.

also it will return the response here i need to do for customization for that output and shown to user.

here i have an request in the form json the thing is i need to pass the request not in json format, i need to pass the request in the form of text.

almost i have done now i am struggling the regex search and replace flow can you help me to fix this issue 

for your reference i have attached the OML and error msg i got in postman 

SandBox.oml

Hi Karthick,

Have you debugged your code? In the Post API method, have you checked whether the data you receive in the Request input parameter is the data you expect?

As for the Customization action, why are you using Regex_Replace instead of just the built-in Replace action? That should suffice here. Regardless, the first Regex_Replace should work, removing all slashes. The second RegEx_Replace however does not work, as you are removing all double quotes, which results in invalid JSON. So your JSONDeserialize will surely fail.

What I would do, is instead of using the RegEx_Replaces, use a single Replace (in an assignment), replacing the \" with ", like this:

Replace(Request, "\""", """")

That should get rid of the escaped double quotes (and replace them by normal quotes). Then the only thing you need to do is remove the leading and trailing double quote, which you could do with Substr (again, in an assignment):

Substr(Request, 1, Length(Request) - 2)


i have tried that one also i am getting this kind error at postman

{

    "Errors": [

        "Failed to deserialize JSON to CustomziedResponse:\nError converting value \"{\" to type 'ssSandBox.RestRecords.JSONSTCustomziedResponseStructure'. Path '', line 1, position 3."

    ],

    "StatusCode": 500

}

Try debugging the Customize action, and see if after the Replace, the JSON contains what you expect it to be. If that's the case, try creating a structure from JSON (use the context menu of the Structures folder:

) and see if the created structure looks any different from the one you have created manually (assuming that's what you did).


while debugging i am able get the proper format even i am created the response as you told only i am making but still i am getting  the error please help me to fix this issue


basically in deserialize i am padding the datatype for the response structure if it is right or wrong.

because the response structure is modified or customized one for users.

You still have the double quotes at the start (en possibly end) of the JSON, which is not good. Did you do the Substr?

i have used that one but in postman i am able to get the status and message only that data is missing.

how we can mapping the different structure with different structure

I don't understand what you are saying. In your last screenshot, there's still a double quote in the data:

Please debug your app and make sure that the double quote is gone before you try Deserializing it.

yes there is no quotes before deserilazing but the issue is i am not getting the proper response 

actual response is this one.

Response

{

  "status": "SUCCESS",

  "message": "All Good!",

  "data": {

    "ParentList": [

      {

        "ParentID": 7,

        "name": "Congruent",

        "role_id": 1,

        "role_name": "superuser",

        "Children": [

          {

            "collection": {

              "collectionID": 45,

              "name": "125 EMS Hotel LLC",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 48,

              "name": "24 Hour Fitness USA",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 49,

              "name": "250 East Ponce Owner",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 50,

              "name": "3PLAi",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 51,

              "name": "4_WHEEL_AUTO_PARTS",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 52,

              "name": "50_East_Chestnut_Condos",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 53,

              "name": "Acton_Academy",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 54,

              "name": "ADVANTAGE_TERMITE",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 55,

              "name": "Aegis_Living",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 56,

              "name": "AG-ARA_TOWN_CENTER",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 57,

              "name": "Aimbridge_Hospitality",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 58,

              "name": "AIMCO",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 59,

              "name": "AJAPPJR",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 60,

              "name": "ALH_Med_Center",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 61,

              "name": "ALH_West_Loop",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 62,

              "name": "ALMC_Suwanee",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 63,

              "name": "Ancon_Marine",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 64,

              "name": "For_Eyes_Optical",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 140,

              "name": "TEST",

              "role_id": 1,

              "role_name": "superuser"

            }

          }

        ]

      },

      {

        "ParentID": 8,

        "name": "Global",

        "role_id": 1,

        "role_name": "superuser",

        "Children": [

          {

            "collection": {

              "collectionID": 45,

              "name": "125 EMS Hotel LLC",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 48,

              "name": "24 Hour Fitness USA",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 49,

              "name": "250 East Ponce Owner",

              "role_id": 1,

              "role_name": "superuser"

            }

          }

        ]

      }

    ]

  }

but i am getting this one if it is possible to assign the response in different structure can i modified the response its possible

{

    "status": "SUCCESS",

    "message": "AllGood!"

}


almost completed this one only i am lagging please help me to fix this one 


thanks and regards 

karthick

Hi Karthick,

The structure you have defined as output seems correct, so if you only get those two lines, this means that you didn't fill your data. OutSystems, by default, does not output empty attributes. So if you don't see those attributes, that means that there's no data in them (ParentList is empty).

if youdon't mine can you help to mapping those values please outsystems really new for me please help me fix this issue

paraent list is not empty the parent list is,

  "data": {

    "ParentList": [

      {

        "ParentID": 7,

        "name": "Congruent",

        "role_id": 1,

        "role_name": "superuser",

        "Children": [

          {

            "collection": {

              "collectionID": 45,

              "name": "125 EMS Hotel LLC",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 48,

              "name": "24 Hour Fitness USA",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 49,

              "name": "250 East Ponce Owner",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 50,

              "name": "3PLAi",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 51,

              "name": "4_WHEEL_AUTO_PARTS",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 52,

              "name": "50_East_Chestnut_Condos",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 53,

              "name": "Acton_Academy",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 54,

              "name": "ADVANTAGE_TERMITE",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 55,

              "name": "Aegis_Living",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 56,

              "name": "AG-ARA_TOWN_CENTER",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 57,

              "name": "Aimbridge_Hospitality",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 58,

              "name": "AIMCO",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 59,

              "name": "AJAPPJR",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 60,

              "name": "ALH_Med_Center",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 61,

              "name": "ALH_West_Loop",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 62,

              "name": "ALMC_Suwanee",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 63,

              "name": "Ancon_Marine",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 64,

              "name": "For_Eyes_Optical",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 140,

              "name": "TEST",

              "role_id": 1,

              "role_name": "superuser"

            }

          }

        ]

      },

      {

        "ParentID": 8,

        "name": "Global",

        "role_id": 1,

        "role_name": "superuser",

        "Children": [

          {

            "collection": {

              "collectionID": 45,

              "name": "125 EMS Hotel LLC",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 48,

              "name": "24 Hour Fitness USA",

              "role_id": 1,

              "role_name": "superuser"

            }

          },

          {

            "collection": {

              "collectionID": 49,

              "name": "250 East Ponce Owner",

              "role_id": 1,

              "role_name": "superuser"

            }

          }

        ]

      }

    ]

  }




thanks and regards

karthick

SandBox.oml

You are not setting ParentList:

That is in Customization. In Post, where you set the Response, there's also no assign to ParentList. So nowhere you assign ParentList. So it makes sense it's empty right? This has little to do with OutSystems, this is basic programming: you need an assign to set data.


my question in deserializing what kind of structure i need to pass once that wanted response only right?

if i am assiging the wanted structure means i am not getting any error while assiging but in response i am not able to get that i shared earlier that postman results

sorry for that but in my response is different one even i am modified that response added some attributes.

i am trying to assign that it show datatype compatiable error i am not able to assign it.

 

Solution

Since "Data" only contains a "ParentList", the mapper doesn't show "Data" seperately, but only "Data.ParentList". So you need to assign the ParentList with the same datatype, as you cannot map in a mapping. Since RawResponse is a structure, not a list, you could just put the assign below that, and map if needed:

Note that OutSystems is a strongly-typed language, so you need to specify the conversion (mapping) if you have different data types.


tq so much o have tried to mapping but i am not able to do that because i don't have that much of knowledge in outsystems if you don't mine can you try the mapping for me once.i am not able to do that.

thanks 

You already created a mapping (see the screenshot above) when assigning "JSONDeserializeCustomziedResponse.Data to RawResponse.

In this case, I can't provide a mapping even if I wanted to, as the example Sandbox module does not have any data I could use for the mapping.

Hi sorry for late reply but I am trying to understand better your response; according to your logic the last assignment should be: RawResponse.Data=Data.ParentList  correctl? You have it blank in your screen shot

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.