
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
POST JSON with REST API
Hello,
I need to send data from a JSON file from Talend with REST API.
To verify that my file and my POST URL is working, I did the test on Postman without error, it allows to create new object in my tools.
I need it to work since Talend, because it will be industrialized later but I can not do it.
Here the contents of my JSON file:
"{
"path": "/Catalogue_Produits/Respiratoire/",
"elements": [
{
"type": "input",
"value": "Respi test 1 RESTAPIxxxx",
"name": "Denom",
"language": null
},
{
"type": "input",
"value": "RESPI test 1 RESTAPIxxxxx",
"name": "Nom_Data",
"language": null
},
{
"type": "select",
"value": "NouveauProduit",
"name": "PROCESSUS_SEL",
"language": null
}
],
"className": "Product",
"parentId": 98,
"key": "Respi3000",
"published": true,
"type": "object"
}"
Here the test ok on Postman:
I am new to Talend, but I tried to add the components:
tFileInputJSON => row => tRest_Client
The setting must be wrong because it does not work.
Can you help me ?
Thank you
- « Previous Replies
-
- 1
- 2
- Next Replies »
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your HTTP Body is empty, you should be passing the value that is sent from the tFileInputRaw. See my first Screenshot:
Where 'row1' is the row leading from tFileInputRaw and 'content' is what represents the content of the file. (Clicking the row itself, then the component button will let you see what the schema is defined as)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try using a tRest instead of a tRestClient to POST w/ a body. You can past the raw JSON directly in the HTTP body section (make sure to escape your double quotes though)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it does not work, I added "\" in front of the quotation marks but it does not change anything :
The error :
The code :
Thank you for your help

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tFileInputJSON should only be used if you need to extract the columns from a JSON file. Because the body of the POST does not require that(i.e. you can send the raw text), then you don't have to use tFileInputJSON. You are getting those compiler warnings because you have extracted those values into a schema and tRest does not need them. Instead use a tfileInputRaw and pass the data into the body of the tRest. I tested w/ a dummy api

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
@evansdar, it works almost!
The data does not seem to have arrived in the correct format because I get an error.
I rechecked with POSTMAN and the contents of the JSON file is correct.
Would you have an idea?
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're still using tRestClient, swap to tRest. You'll have to put a tFlowToIterate in between them to connect.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@evansdar, I can not find the component tFlowTolterate in Talend

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The data are ok in log :
Démarrage du job test10 a 14:53 06/02/2019.
[statistics] connecting to socket on port 3877
[statistics] connected
.--------------------------------------+----------.
| tLogRow_1 |
|=-------------------------------------+---------=|
|Body |ERROR_CODE|
|=-------------------------------------+---------=|
|{"success":false,"msg":"Invalid data"}|400 |
'--------------------------------------+----------'
.-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
| tLogRow_2 |
|=-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------=|
|content |
|=-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------=|
|{
"path": "/Catalogue_Produits/Respiratoire/",
"elements": [
{
"type": "input",
"value": "ALEX",
"name": "Denom",
"language": null
},
{
"type": "input",
"value": "ALEX",
"name": "Nom_Data",
"language": null
},
{
"type": "select",
"value": "NouveauProduit",
"name": "PROCESSUS_SEL",
"language": null
}
],
"className": "Product",
"parentId": 51,
"key": "ALEX",
"published": true,
"type": "object"
}|
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
[statistics] disconnected
Job test10 terminé à 14:53 06/02/2019. [Code sortie=0]

- « Previous Replies
-
- 1
- 2
- Next Replies »