Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
M_ADN
Contributor
Contributor

Erreur bad request 400 (tRestClient, méthode post, Talend)

Bonjour,

 

J’ai une erreur lors d’envoi d’un message JSON vers une API  Rest en utilisant le composant Talend tRestClient

 

Ci-dessous l’erreur affichée dans la console :

Exception in component tRESTClient_1 (test_call_api_rest)
javax.ws.rs.WebApplicationException: HTTP 400 Bad Request

 

Ci-dessous la conception de mon job :

 

0683p000009Ma4b.png

 

La requête Json est stockée dans une variable définie dans le tMap comme suit

new String ("{\"type\": \"test_update\",\"payload\":{\"resource\": \"tea\",\"civility\":\"Dr\",\"last_name\":\"Premier\",\"first_name\":\"Nombre\",\"status\":\"P\",\"title\":\"Professeur Niveau 2\",\"contract_start_date\":\"test\",\"contract_end_date\":\"test\",\"speaker_code\":\"INT\",\"email\":\"test\",\"email_pro\":\"test\",\"main_disciplinary_group_fr\":\"test\",\"main_disciplinary_group_en\":\"test\",\"minor_disciplinary_group_fr\":\"test\",\"minor_disciplinary_group_en\":\"test\",\"speaker_type_fr\":\"Core Faculty\",\"speaker_type_en\":\"Core Faculty\",\"classification_fr\":\"Recherche\",\"classification_en\":\"Research\",\"UB_fr\":\"test\",\"UB_en\":\"test\",\"file_statut\":\"test\"}}") 

 

Vous trouverez ci-dessous la configuration du composant tRestClient :

Basic :

 

0683p000009MaR5.png

Advanced :

 

0683p000009MaRA.png

J’ai testé aussi la requête via postman et le résultat est ok :

0683p000009MaNO.png

 

Bien que  j’ai bien configuré les paramètres du compostant tRestClient et j’ai bien échappé les doubles quotte du message à envoyer, j’ai une erreur 404 à la place de la réponse 202.

 

Quelqu’un d’entre vous aurait une idée d’où est ce que ça pourrait venir ?

 

Merci d’avance.

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

tRestClient is waiting for a schema with 2 fields called "string" and "body".
Review the tMap output schema with these fields (type String and Document) where "string" must replace your "var1" field.

View solution in original post

11 Replies
TRF
Champion II
Champion II

How is defined the tMap output schema?
What field is supposed to be used to pass the payload from tMap to tRestClient?
M_ADN
Contributor
Contributor
Author

bonjour, 

merci de votre réponse. 

ci-dessous une capture de la configuration de mon tMap:  

0683p000009MaRF.png

Le message est défini dans une variable de type String que je transmis à tRestClient via la variable var1. 

 

Merci d'avance de votre retour. 

Cordialement

TRF
Champion II
Champion II

tRestClient is waiting for a schema with 2 fields called "string" and "body".
Review the tMap output schema with these fields (type String and Document) where "string" must replace your "var1" field.
M_ADN
Contributor
Contributor
Author

Bonjour,

 

je vous remercie pour votre retour.

 

la solution que vous m'avez proposé fonctionne parfaitement lors de ce que j'envoie un seul message.

 

sauf que, maintenant je souhaite envoyer la même structure du message mais en boucle.

 

Veuillez trouver ci-dessous un exemple de message que je souhaite envoyer et j'ai la même erreur "Erreur bad request 400".

 

{\"type\": \"test_update\",\"payload\":[{\"resource\": \"tea\",\"civility\":\"Dr\",\"last_name\":\"Premier\",\"first_name\":\"Nombre\",\"status\":\"P\",\"title\":\"Professeur Niveau 2\",\"contract_start_date\":\"test\",\"contract_end_date\":\"test\",\"speaker_code\":\"INT\",\"email\":\"test\",\"email_pro\":\"test\",\"main_disciplinary_group_fr\":\"test\",\"main_disciplinary_group_en\":\"test\",\"minor_disciplinary_group_fr\":\"test\",\"minor_disciplinary_group_en\":\"test\",\"speaker_type_fr\":\"Core Faculty\",\"speaker_type_en\":\"Core Faculty\",\"classification_fr\":\"Recherche\",\"classification_en\":\"Research\",\"UB_fr\":\"test\",\"UB_en\":\"test\",\"file_statut\":\"test\"},{\"resource\": \"tea\",\"civility\":\"Dr\",\"last_name\":\"Premier\",\"first_name\":\"Nombre\",\"status\":\"P\",\"title\":\"Professeur Niveau 2\",\"contract_start_date\":\"test\",\"contract_end_date\":\"test\",\"speaker_code\":\"INT\",\"email\":\"test\",\"email_pro\":\"test\",\"main_disciplinary_group_fr\":\"test\",\"main_disciplinary_group_en\":\"test\",\"minor_disciplinary_group_fr\":\"test\",\"minor_disciplinary_group_en\":\"test\",\"speaker_type_fr\":\"Core Faculty\",\"speaker_type_en\":\"Core Faculty\",\"classification_fr\":\"Recherche\",\"classification_en\":\"Research\",\"UB_fr\":\"test\",\"UB_en\":\"test\",\"file_statut\":\"test\"}]}

 

Emploi Ci-dessous mon sous:

0683p000009MaXh.png

 

ci-dessous la configuration du tMap

 

0683p000009MaXm.png

 

J'ai testé aussi la requête via le facteur et le résultat est ok.

 

merci pour votre aide.

 

Cordialement,

 

 

M_ADN
Contributor
Contributor
Author

Bonjour,

 

je vous remercie pour votre retour.

 

la solution que vous m'avez proposé fonctionne parfaitement lors de ce que j'envoie un seul message.

 

sauf que, maintenant je souhaite envoyer la même structure du message mais en boucle.

 

Veuillez trouver ci-dessous un exemple de message que je souhaite envoyer et j'ai la même erreur "Erreur bad request 400".

 

{\"type\": \"test_update\",\"payload\":[{\"resource\": \"tea\",\"civility\":\"Dr\",\"last_name\":\"Premier\",\"first_name\":\"Nombre\",\"status\":\"P\",\"title\":\"Professeur Niveau 2\",\"contract_start_date\":\"test\",\"contract_end_date\":\"test\",\"speaker_code\":\"INT\",\"email\":\"test\",\"email_pro\":\"test\",\"main_disciplinary_group_fr\":\"test\",\"main_disciplinary_group_en\":\"test\",\"minor_disciplinary_group_fr\":\"test\",\"minor_disciplinary_group_en\":\"test\",\"speaker_type_fr\":\"Core Faculty\",\"speaker_type_en\":\"Core Faculty\",\"classification_fr\":\"Recherche\",\"classification_en\":\"Research\",\"UB_fr\":\"test\",\"UB_en\":\"test\",\"file_statut\":\"test\"},{\"resource\": \"tea\",\"civility\":\"Dr\",\"last_name\":\"Premier\",\"first_name\":\"Nombre\",\"status\":\"P\",\"title\":\"Professeur Niveau 2\",\"contract_start_date\":\"test\",\"contract_end_date\":\"test\",\"speaker_code\":\"INT\",\"email\":\"test\",\"email_pro\":\"test\",\"main_disciplinary_group_fr\":\"test\",\"main_disciplinary_group_en\":\"test\",\"minor_disciplinary_group_fr\":\"test\",\"minor_disciplinary_group_en\":\"test\",\"speaker_type_fr\":\"Core Faculty\",\"speaker_type_en\":\"Core Faculty\",\"classification_fr\":\"Recherche\",\"classification_en\":\"Research\",\"UB_fr\":\"test\",\"UB_en\":\"test\",\"file_statut\":\"test\"}]}

 

Emploi Ci-dessous mon sous:

0683p000009MaXh.png

 

ci-dessous la configuration du tMap

 

0683p000009MaXm.png

 

J'ai testé aussi la requête via le facteur et le résultat est ok.

 

merci pour votre aide.

 

Cordialement,

 

 

M_ADN
Contributor
Contributor
Author

Bonjour,

 

je suis toujours bloqué sur 2eme point cités ci-dessus.

 

je vous remercie pour votre aide.

 

Cordialement,

M_ADN
Contributor
Contributor
Author

Bonjour,

 

je suis toujours bloqué sur 2eme point cités ci-dessus.

 

je vous remercie pour votre aide.

 

Cordialement,

TRF
Champion II
Champion II

Does it works when using a external tool such as Postman?

This is to know if the problem is due to the tRestClient settings or to the message format which is maybe not as expected by the called service. 

TRF
Champion II
Champion II

Does it works when using a external tool such as Postman?

This is to know if the problem is due to the tRestClient settings or to the message format which is maybe not as expected by the called service.