How to stop the cREST exchange body from getting truncated when sending JSON without root node ?

Highlighted
Four Stars

How to stop the cREST exchange body from getting truncated when sending JSON without root node ?

Hi,

I'm using Talend Open Sudio for ESB 7.1.1 (free version) and have a simple route: cRest --> cProcessor.

My cRest has "Consumes" and "Produces" set to "JSON".

My cProcessor prints the "in" part of the exchange to the console: System.out.println("in body = '" + exchange.getIn().getBody(String.class) + "'");

When I send a JSON POST request to the cRest without a root node, eg:

{
  "mid": "18125",
  "portalid": "2013194"
}

I get the following truncated output on the console: in body = '<mid>18125</mid>'. How do I get the rest of the JSON request, ie. <portalid>2013194</portalid> ?

I need all the values in the exchange in body for further processing.

 

If I send a JSON POST request with a root node, I do get all values from the request (in body = '<root><mid>18125</mid><portalid>2013194</portalid></root>'),

BUT: I can't change the client making the JSON Post, so I'm stuck.

 

In the Code view for the Route it shows

    providers.add(new com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider());
    providers.add(new com.fasterxml.jackson.jaxrs.xml.JacksonJaxbXMLProvider());

 

In the Route POM it shows

<dependency>
<groupId>org.talend.libraries</groupId>
<artifactId>jackson-jaxrs-json-provider-2.9.6</artifactId>
<version>6.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.talend.libraries</groupId>
<artifactId>cxf-rt-rs-client-3.2.6</artifactId>
<version>6.0.0-SNAPSHOT</version>
</dependency>

 

According to this post, it should just work out of the box:

https://stackoverflow.com/questions/30037200/how-to-define-model-to-unmarshall-post-data-without-roo...

 

How can i make this work ?

Your help is greatly appreciated.

 

 

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read