IBM TechXchange Group

 View Only

List of JSON methods allowed in apim module

  • 1.  List of JSON methods allowed in apim module

    Posted Mon August 26, 2024 08:23 PM

    Hello All,

    I have a use case where in I need to call an ACE service with HTTP POST request and the service is returning a payload like:

    {
            "NotificationRs": {
                "MsgRsHdr": {
                    "ResponseStatus": {
                        "StatusCode": "I000000",
                        "StatusDesc": "Successful DB operation"
                    }
                },
                "Notifications": "[{\"notification_id\":\"100001530\",\"notification_name\":\"Self Service\",\"title\":\"Test Title 2\",\"t_content\":\"Test Content 2\",\"updated_date\":\"06-JUN-2024 00:00:00\",\"is_read\":\"\",\"is_read_date\":\"\"},{\"notification_id\":\"100001531\",\"notification_name\":\"Self Service\",\"title\":\"Test Title 2\",\"t_content\":\"Test Content 2\",\"updated_date\":\"06-JUN-2024 00:00:00\",\"is_read\":\"\",\"is_read_date\":\"\"},{\"notification_id\":\"100001536\",\"notification_name\":\"Self Service\",\"title\":\"Test Title 2\",\"t_content\":\"Test Content 2\",\"updated_date\":\"06-JUN-2024 00:00:00\",\"is_read\":\"\",\"is_read_date\":\"\"},}"}}}

    So I am attempting to clean this message on API Connect in a subsequent gatewayscript action in the assembly, and setting the reconstructed string value of NotificationsRs.Notifications into a JSON Array, but so far I have no luck
    I am importing the apim module
    Then I am using the JSON.parse()
    Then using JSON.stringify() to set it to the message.body/......but there's no change in the payload.
    Hence I doubt that JSON.parse() even works when importing the apim module.....
    Need your advise on this


    ------------------------------
    Bikramjit Purkayastha
    ------------------------------