Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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.

 

 

 

Labels (2)
2 Replies
Anonymous
Not applicable
Author

Any Solution for this thing?

Anonymous
Not applicable
Author

I ended up parsing the Json values posted to the route with the cCXFRS component instead:

 

cCXFRS->cConvertBodyTo->cSetHeader

 

Settings: 

 

1. cCXFRS: HTTP Verb = POST, consumes/produces = JSON, Bean class = String

2. cConvertBodyTo: String

3. cSetHeader: VariableName = test, JsonPath, "<name of Json attribute>", String.class


cSetHeader.png