API Mashup payload jsonpath

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.

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.

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

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

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

Any comments?

Thank you again.

Regards

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?

Hello @juan.villalon

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

Regards,
Bharath

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.

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.

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.