1 Reply Latest reply on Mar 26, 2020 8:11 AM by Mehul Sorathiya

    Unable to Parse JSON body Input from REST Client

    Mehul Sorathiya Seasoned Veteran

      Hello,

       

      I need to pass below JSON body in POST operation for one of my CAI process which will be the input to Service Connector.

       

      {

      "abc": {

      "efg": {

      "item": [{

      "_price": "15",

      "_quantity": "book",

      "_number": "1234"

      },

      {

      "_price": "12",

      "_quantity": "price",

      "_number": "1657"

      }

      ]

      },

      "lmn": "Integration"

      }

       

      }

       

      I have defined Input as Whole Payload with Any type. Internally process server converts all input to XML element so I have used toJSON function to retain the JSON input for Service Connector input. This toJSON conversion is failing with error "Cannot convert string "price" to an integer". I'm not sure why it's assuming this field as integer because in the body it is defined as string only.

       

      For a workaround, I have created Process Objects to define the structure of entire body and its working fine excepts "item" process object.

       

      It contains fields (_price) which starts with underscores and Informatica doesn't allow to create field name starting with underscores. The name should start with a letter always.

       

      Please let me know if we have any workaround for this process object limitations and if there is another approach to consume this JSON body.

       

      Thanks in advance.

       

      -Mehul

        • 1. Re: Unable to Parse JSON body Input from REST Client
          Mehul Sorathiya Seasoned Veteran

          Hi All -

           

          As discussed with Informatica support team, This is product issue in which if the all  names starts from '_'  ,internally it consider it as an array and expects the first field  as an integer.

           

          This issue will be tracked as a part of 'ICAI-17633'.

           

          For a workaround, I have prepared the entire request in XML format without underscore using Xquery, converted it into JSON using util:toJson() and have put the underscores using fn:replace().