Bonjour,
j'essaye d’exécuter une commande CURL que je variabilise dans un script shell.
La requête refuse de s’exécuter mais le echo que j'associe à cette requete pour debuger me donne une requete qui marche bien...
Voici mon code :
Voici le retour de script :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #!/bin/bash #FONCTION REQUETE CURL + LOG callCurl(){ CURL="curl -H \"X-CORRELATIONID: ${3}\" -H \"X-TRANSACTIONID: ${4}\" -H \"X-USERID-TECH: ${5}\" -H \"X-USERID-TARGET: ${6}\" -H \"Content-type: application/json\" -X \"POST\" -d ${7} ${1}/${2}" echo -e "Echo n°2" echo -e $CURL $CURL } # PARAMETRES REQUETE HOST=localhost PORT=9300 VERSION=trunk URL="http://${HOST}:${PORT}/${VERSION}" CONTENT_CHECKEMAIL="'{\"email\":\"toto@toto.com\"}'" CORRELATIONID=TOTO TRANSACTIONID=TATA USERIDTECH=TITI USERIDTARGET=TUTU # EXECUTION REQUETE echo -e "Echo n°1" echo -e "callCurl $URL checkEmailExists $CORRELATIONID $TRANSACTIONID $USERIDTECH $USERIDTARGET $CONTENT_CHECKEMAIL" callCurl $URL checkEmailExists $CORRELATIONID $TRANSACTIONID $USERIDTECH $USERIDTARGET $CONTENT_CHECKEMAIL
Quand j'execute le résultat de echo n°2, ca marche super bien.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 Echo n°1 callCurl http://localhost:9300/trunk checkEmailExists TOTO TATA TITI TUTU '{"email":"toto@toto.com"}' Echo n°2 curl -H "X-CORRELATIONID: TOTO" -H "X-TRANSACTIONID: TATA" -H "X-USERID-TECH: TITI" -H "X-USERID-TARGET: TUTU" -H "Content-type: application/json" -X "POST" -d '{"email":"toto@toto.com"}' http://localhost:9300/trunk/checkEmailExists curl: (6) Couldn't resolve host 'TOTO"' curl: (6) Couldn't resolve host 'TATA"' curl: (6) Couldn't resolve host 'TITI"' curl: (6) Couldn't resolve host 'TUTU"' curl: (6) Couldn't resolve host 'application' The request could not be understood by the server due to malformed syntax.
Je suis au bout. Je paye une pinte au premier qui me donne la solution
Manu
Partager