Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I encounter 2 unsolvable issues on Talend ESB tRESTRequest component (i beg).
I created an ESB job beggining with a tRESTRequest component (POST mode) as a first step, which has to process the web service call posting a Json formatted document.
Unfortunately, all my test attempts end up with the following error raise :
"[WARN ]: org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper - javax.ws.rs.BadRequestException: HTTP 400 Bad Request"
"Caused by: org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: Un caractère XML non valide ou non admis est indiqué. "
The JSon document to process contains :
"taxes": {
"745BDD811EB9438DA4682086CB0B6F52": {
"id": "745BDD811EB9438DA4682086CB0B6F52",
"net": 24.17,
"amount": 4.83,
"name": "TVA 20% FR",
"docTaxAmount": "D",
"rate": 20,
"taxBase": null,
"cascade": false,
"lineNo": 10
}
}
Without those fields/special nodes in the Json document, everything works fine and i have no problem.
Thanks by advance for all your comments/advices !
Rémi
Hi
It is an invalid Json string, the json API can not parse it and throws the error, we can do nothing on Json API, is it possible to update the json string to an valid one before passing it web service?
Regards
Shong
Hi shong and thx for your precious feedback.
Is there any way of bypassing the auto-convertion in the tRESTRequest ? I mean, could we use another Talend component just before the tRESTRequest uses its json API auto-parsing, to clean this formatting issues ?
And for you, according to your answer, what is really incorrect in this Json ?
thx a lot !
Rémi
Hi Remi,
How do you pass this Json string to web service? tRestRequest does not have the auto-convertion functionality, the json string should be corrected before web service is calling.
There are some online Json validator, such as https://jsonlint.com/, you can check the json string.
Regards
Shong
hi shong and thx for your replies.
I don't have any control over the WS Call. It comes from an application, for which i asked some adjustments because of this issue in Talend. Moreover the technical managers of this application maintain they had not encountered such issue about the json format, which is a correct one for them.
It's curious because when i post en example of Json on the link you provided me, it tells me it's a valid json ! But it can't go through a Talend ESB tRESTRequest without crashing it with a "404 bad request", as soon as i keep the field name containing "$" properties and the weird taxes node with the "value itself without any key name".
That keeps me puzzled 🙂
I tested the example json provided by you in the first post and it shows invalid. How do you pass the Json to tRESTRequest? Through parameters?
Hi if you want to make it valid, just encapsulate the wole with {} :
{
"taxes":{
"745BDD811EB9438DA4682086CB0B6F52":{
"id":"745BDD811EB9438DA4682086CB0B6F52",
"net":24.17,
"amount":4.83,
"name":"TVA 20% FR",
"docTaxAmount":"D",
"rate":20,
"taxBase":null,
"cascade":false,
"lineNo":10
}
}
}
will work, but here it's just a node you send it's not the full json
could you send a full created json ? To see what you have to transform to make it valid ?
:
it is ok cause his value is a list of value in the {} just after(but it create a dynamic field name wich is surely not supported on the api parser), you have to see the structure the api want for your json.
and $ in field name doesn't seem to cause any problem for a valid json but will can create error on some parser you could use $$ instead it seems to work.