[
https://issues.apache.org/jira/browse/CAMEL-20100?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Damir Palinic updated CAMEL-20100:
----------------------------------
Description:
When json response is received from the external REST endpoint using camel-http
component, it fails to read missing json value, although
DEFAULT_PATH_LEAF_TO_NULL option is set.
This can be reproduced using mockable.io service, but we noticed this behavior
when calling many other REST endpoints (from real implementations).
How to reproduce:
# Create mocked POST REST endpoint using mockable.io
# For example, our looks like following:
`POST [http://demo0405481.mockable.io/camel]`
Response: \{"errorcode":0,"errormessage":""}
# Create integration where REST endpoint from step 2. is called using
camel-http
# Read missing summary field using Set Property and Jsonpath with
DEFAULT_PATH_LEAF_TO_NULL enabled
# Observe the error "Cannot read message body as supported JSON value. "
Actual result:
{code:java}
org.apache.camel.ExpressionEvaluationException:
org.apache.camel.CamelExchangeException: Cannot read message body as supported
JSON value. {code}
Expected result:
{code:java}
${exchangeProperty.summary} to be null
{code}
YAML DSL to reproduce:
{code:java}
- route:
nodePrefixId: route-7e2
id: route-dafc
from:
uri: scheduler
id: from-64dc
parameters:
name: scheduler
repeatCount: 2
steps:
- setHeader:
name: Content-Type
expression:
simple:
expression: application/json
id: simple-dc79
id: setHeader-2f26
- setBody:
expression:
simple:
expression: |-
{
"some": "value"
}
id: simple-bfca
id: setBody-243c
- to:
uri: http
id: to-2cfa
parameters:
httpUri: demo0405481.mockable.io/camel
httpMethod: POST
- setProperty:
name: summary
expression:
jsonpath:
expression: $.summary
option: DEFAULT_PATH_LEAF_TO_NULL
id: jsonpath-54df
id: setProperty-0d81
- log:
message: 'Value: ${exchangeProperty.summary}'
id: log-6839
{code}
Additional notes:
* Please create your own mock using mockable.io and create some POST REST
endpoint and return any json you want
* In case summary field exists, it reads it normally
* In case body is set using Set Body component, instead of reading it from
from REST endpoint, everything works fine
was:
When json response is received from the external REST endpoint using camel-http
component, it fails to read missing json value, although
DEFAULT_PATH_LEAF_TO_NULL option is set.
This can be reproduced using mockable.io service, but we noticed this behavior
when calling many other REST endpoints (from real implementations).
How to reproduce:
# Create mocked POST REST endpoint using mockable.io
# For example, our looks like following:
`POST [http://demo0405481.mockable.io/camel]`
Response:
{"errorcode":0,"errormessage":""}
# Create integration where REST endpoint from step 2. is called using
camel-http
# Read missing summary field using Set Property and Jsonpath with
DEFAULT_PATH_LEAF_TO_NULL enabled
# Observe the error "Cannot read message body as supported JSON value. "
Actual result:
{code:java}
org.apache.camel.ExpressionEvaluationException:
org.apache.camel.CamelExchangeException: Cannot read message body as supported
JSON value. {code}
Expected result:
{code:java}
${exchangeProperty.summary} to be null
{code}
YAML DSL to reproduce:
{code:java}
- route:
nodePrefixId: route-7e2
id: route-dafc
from:
uri: scheduler
id: from-64dc
parameters:
name: scheduler
repeatCount: 2
steps:
- setHeader:
name: Content-Type
expression:
simple:
expression: application/json
id: simple-dc79
id: setHeader-2f26
- setBody:
expression:
simple:
expression: |-
{
"some": "value"
}
id: simple-bfca
id: setBody-243c
- to:
uri: http
id: to-2cfa
parameters:
httpUri: demo0405481.mockable.io/camel
httpMethod: POST
- setProperty:
name: summary
expression:
jsonpath:
expression: $.summary
option: DEFAULT_PATH_LEAF_TO_NULL
id: jsonpath-54df
id: setProperty-0d81
- log:
message: 'Value: ${exchangeProperty.summary}'
id: log-6839
{code}
Additional notes:
* Please create your own mock using mockable.io and create some POST REST
endpoint and return any json you want
* In case summary field exists, it reads it normally
* In case body is set using Set Body component, instead of reading it from
from REST endpoint, everything works fine
> Camel-jsonpath can't fetch field in some cases when body is returned from a
> http/https call
> -------------------------------------------------------------------------------------------
>
> Key: CAMEL-20100
> URL: https://issues.apache.org/jira/browse/CAMEL-20100
> Project: Camel
> Issue Type: Bug
> Components: camel-jsonpath
> Affects Versions: 4.1.0
> Reporter: Damir Palinic
> Priority: Major
>
> When json response is received from the external REST endpoint using
> camel-http component, it fails to read missing json value, although
> DEFAULT_PATH_LEAF_TO_NULL option is set.
> This can be reproduced using mockable.io service, but we noticed this
> behavior when calling many other REST endpoints (from real implementations).
> How to reproduce:
> # Create mocked POST REST endpoint using mockable.io
> # For example, our looks like following:
> `POST [http://demo0405481.mockable.io/camel]`
> Response: \{"errorcode":0,"errormessage":""}
> # Create integration where REST endpoint from step 2. is called using
> camel-http
> # Read missing summary field using Set Property and Jsonpath with
> DEFAULT_PATH_LEAF_TO_NULL enabled
> # Observe the error "Cannot read message body as supported JSON value. "
> Actual result:
> {code:java}
> org.apache.camel.ExpressionEvaluationException:
> org.apache.camel.CamelExchangeException: Cannot read message body as
> supported JSON value. {code}
> Expected result:
> {code:java}
> ${exchangeProperty.summary} to be null
> {code}
> YAML DSL to reproduce:
> {code:java}
> - route:
> nodePrefixId: route-7e2
> id: route-dafc
> from:
> uri: scheduler
> id: from-64dc
> parameters:
> name: scheduler
> repeatCount: 2
> steps:
> - setHeader:
> name: Content-Type
> expression:
> simple:
> expression: application/json
> id: simple-dc79
> id: setHeader-2f26
> - setBody:
> expression:
> simple:
> expression: |-
> {
> "some": "value"
> }
> id: simple-bfca
> id: setBody-243c
> - to:
> uri: http
> id: to-2cfa
> parameters:
> httpUri: demo0405481.mockable.io/camel
> httpMethod: POST
> - setProperty:
> name: summary
> expression:
> jsonpath:
> expression: $.summary
> option: DEFAULT_PATH_LEAF_TO_NULL
> id: jsonpath-54df
> id: setProperty-0d81
> - log:
> message: 'Value: ${exchangeProperty.summary}'
> id: log-6839
> {code}
> Additional notes:
> * Please create your own mock using mockable.io and create some POST REST
> endpoint and return any json you want
> * In case summary field exists, it reads it normally
> * In case body is set using Set Body component, instead of reading it from
> from REST endpoint, everything works fine
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)