IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation

 View Only
Expand all | Collapse all

API Mashup payload jsonpath

  • 1.  API Mashup payload jsonpath

    Posted Tue December 06, 2022 06:02 PM

    API GATEWAY with Mashup

    The version is cloud and API GATEWAY number version is 10.15.0.0.96.

    I’m trying to send into an API Mashup an array json:

    {
    “crPlace”: “10MON”,
    “crStore”: “50AAH”,
    “sku”:[“7501055320660”,“7501011121980”]
    }

    And I’m trying to send this value with payload transformation:

    image

    {
    “crPlace”: “${request.payload.jsonPath[$.crPlace]}”,
    “crStore”: “${request.payload.jsonPath[$.crStore]}”,
    “sku”: “[${request.payload.jsonPath[$.sku[0]}]”
    }

    or

    {
    “crPlace”: “${request.payload.jsonPath[$.crPlace]}”,
    “crStore”: “${request.payload.jsonPath[$.crStore]}”,
    “sku”: [“${request.payload.jsonPath[$.sku]}”]
    }

    or

    {
    “crPlace”: “${request.payload.jsonPath[$.crPlace]}”,
    “crStore”: “${request.payload.jsonPath[$.crStore]}”,
    “sku”: “${request.payload.jsonPath[$.sku]}”
    }

    However, when send the information the error is the following:

    API Gateway encountered an error. Error Message: Native service provider error. Code : 500

    In this case I don’t have access to native service o native server, so I can’t see how the value was sent/received.

    I tried different manners for example with an fixed value:

    {
    “crPlace”: “${request.payload.jsonPath[$.crPlace]}”,
    “crStore”: “${request.payload.jsonPath[$.crStore]}”,
    “sku”: [“7501055320660”]
    }

    In that case it works perfectly. I’m thinking the problem is the manner how to I’m setting the array sku, maybe there some error with jsonpath.

    With another case:

    {
    “crPlace”: “${request.payload.jsonPath[$.crPlace]}”,
    “crStore”: “${request.payload.jsonPath[$.crStore]}”,
    “sku”: [“${request.payload.jsonPath[$.sku[0]}”]
    }

    I get a code 204 No content.

    The API GATEWAY Cloud has the last updates.

    Any idea how to fix that?

    Thanks for your help.

    Regards.


    #API-Gateway
    #webMethods
    #API-Management


  • 2.  RE: API Mashup payload jsonpath

    Posted Tue December 06, 2022 07:24 PM

    In API GW you can log the request/response that is sent to/received from the native service. Might give you a lead on what the syntax of the transform needs to be.

    On quick glance, seems like it may need to be:

    {
    “crPlace”: “${request.payload.jsonPath[$.crPlace]}”,
    “crStore”: “${request.payload.jsonPath[$.crStore]}”,
    “sku”: “${request.payload.jsonPath[$.sku[0]}”
    }
    

    Like your first block but without the [ ] around the var reference.


    #webMethods
    #API-Management
    #API-Gateway


  • 3.  RE: API Mashup payload jsonpath

    Posted Tue December 06, 2022 08:41 PM

    Thank you for your answer, but I would like to send the array complete in mashup, I guess the instruction be like as:

    {
    “crPlace”: “${request.payload.jsonPath[$.crPlace]}”,
    “crStore”: “${request.payload.jsonPath[$.crStore]}”,
    “sku”: “${request.payload.jsonPath[$.sku}]”
    }

    On the other hand, where can see the log of request/response into API GATEWAY, is necessary to active some property?

    Thank you.

    Regards


    #webMethods
    #API-Management
    #API-Gateway


  • 4.  RE: API Mashup payload jsonpath

    Posted Wed December 07, 2022 02:18 PM

    Take a look at the Log Invocation policy for Traffic Monitoring in your API.


    #API-Gateway
    #webMethods
    #API-Management


  • 5.  RE: API Mashup payload jsonpath

    Posted Wed December 07, 2022 04:30 PM

    Thank you so much, however checking the analytics, here the example with reqPayload and resPayload:

    Any comments?

    Thank you again.

    Regards


    #API-Gateway
    #API-Management
    #webMethods


  • 6.  RE: API Mashup payload jsonpath

    Posted Wed December 07, 2022 06:25 PM

    Based upon the screen shot, it looks like it sent what you wanted. The 204 status indicates success and no body – but I see the resPayload, where all the vars have no value, which I don’t think if valid JSON but I’m not entirely certain. Are you able to call the endpoint using a different tool to determine if what is seen in the GW occurs with another tool?


    #API-Gateway
    #API-Management
    #webMethods


  • 7.  RE: API Mashup payload jsonpath

    Posted Wed December 07, 2022 11:10 PM

    Hello @juan.villalon

    Can you use tracer to capture the request and response , which might helpful to debug further.

    Regards,
    Bharath


    #API-Gateway
    #webMethods
    #API-Management


  • 8.  RE: API Mashup payload jsonpath

    Posted Thu December 08, 2022 11:14 AM

    The API has a trace policy, and I can see payload in the analytics, or do you know is there any option to configurate and see details of request and response?

    Thank you.

    Regards.


    #API-Management
    #API-Gateway
    #webMethods


  • 9.  RE: API Mashup payload jsonpath

    Posted Thu December 08, 2022 09:54 AM

    Yes, I’am able to call the endpoint using a different tool in this case Postman, in that case I can see the result correctly.


    #API-Management
    #API-Gateway
    #webMethods


  • 10.  RE: API Mashup payload jsonpath

    Posted Thu December 08, 2022 03:19 PM

    Are you able to share the payloads for comparison?

    Using the Log Invocation Policy will capture the request sent to the native service and the response received. Which looks like what you shared earlier. Tracer can be used too but the logging policy should be sufficient – can capture headers and/or payloads for the request and/or response. That will show you what your transform produced and sends to the native service.


    #API-Gateway
    #webMethods
    #API-Management