Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exemple de commande curl
#1
Hello,

Un petit problème bête... ça fait longtemps que je n'ai pas fait de requête curl sur le serveur Calaos et je tourne en rond ça ne fonctionne pas... Auriez-vous un exemple d'une commande curl sous la main ? ça sera plus rapide  Big Grin

Je fais :
Code:
curl -v -X POST -H "Content-Type: application/json" --insecure -d @./salon_spot.json https://192.168.0.100/api.php



Avec le fichier salon_spot.json suivant:
Code:
{"cn_user": "mon_login",
"cn_pass": "mon_pass",
"action": "set_state",
"type": "output",
"id": "output_4", // Variable Calaos 
"value": "true"
}


Ca me retourne ceci:

Code:
pi@node-red:~/kalliope/kalliope_starter_fr/scripts $ curl -v -X POST -H "Content-Type: application/json" --insecure -d @./salon_spot.json https://192.168.0.100/api.php
* Hostname was NOT found in DNS cache
*   Trying 192.168.0.100...
* Connected to 192.168.0.100 (192.168.0.100) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
*  subject: C=FR; ST=FRANCE; L=Paris; O=Calaos; OU=Calaos; CN=calaos.fr; emailAddress=none@calaos.fr
*  start date: 2015-03-30 16:04:55 GMT
*  expire date: 2042-08-14 16:04:55 GMT
*  issuer: C=FR; ST=FRANCE; L=Paris; O=Calaos; OU=Calaos; CN=calaos.fr; emailAddress=none@calaos.fr
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> POST /api.php HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 192.168.0.100
> Accept: */*
> Content-Type: application/json
> Content-Length: 135

* upload completely sent off: 135 out of 135 bytes
< HTTP/1.1 200 OK
< Content-Length: 0
< Connection: close
< Date: Thu, 08 Nov 2018 20:49:52 GMT
* Server lighttpd/1.4.32 is not blacklisted
< Server: lighttpd/1.4.32

* Closing connection 0
* SSLv3, TLS alert, Client hello (1):

Ok.. mais il ne se passe rien... les spots du salon ne s'allument pas. Le JSON est bon parce que le même utilisé via Node-Red allument bien les lumières.
Avec un "journalctl -flu calaos-server", aucune ligne correspondant à la commande n'apparait. 

C'est assez étrange.. surement une erreur bête de ma part mais je tourne en rond  Sad
C'est pour utiliser avec Kalliope, l'assistant vocal personnel (qui fonctionne pas mal  Cool )

Merci de vos lumières  Idea
Calaos v1.1.20 sur Advantech x86 | Calaos Home écran tactile RS232 | Wago 750-841 | DMX RGB LED
Calaos-OS v2.0 sur Advantech x86 | Clé USB
Squeezebox | Raspberry & Scripts maison
Reply
#2
Personne pour me donner un exemple de curl qu'il aurait chez lui par hasard ? Je me débrouillerai avec ça :-) :-) :-)
Calaos v1.1.20 sur Advantech x86 | Calaos Home écran tactile RS232 | Wago 750-841 | DMX RGB LED
Calaos-OS v2.0 sur Advantech x86 | Clé USB
Squeezebox | Raspberry & Scripts maison
Reply
#3
Salut,

Enleve les commentaires dans le fichier json, le "// Variable Calaos"
Le standard JSON ne supporte pas les commentaires...

Sinon ca devrait marcher, faudrait voir dans les logs de calaos-server ce qu'il dit
Raoul,
Calaos Core Dev.
Calaos git sur NUC NUC5PPYH | Wago 750-849 | DALI RGB | Sondes NTC sur 750-464 | Sondes 1Wire DS18B20 avec adaptateur USB DS9490R | Nodes MySensors avec gateway USB | Ecran tactile ELO avec adaptateur USB/RS232 | Squeezebox Duet et Radio | Logitech Harmony Ultimate | Ampli Pioneer VSX921
Reply
#4
haaaaaaaa merci Raoulh !!!!!!
C'était aussi con que ça !! En copiant le json de Node-red j'ai laissé le commentaire "//" qui plante la commande à Calaos utilisée en mode curl   Angry Angry Angry Angry Angry
Je savais que c'était un truc à la con  Angry Angry Angry Angry

Côté log du serveur, je n'avais rien vu justement, mais pas du regarder là où il faut surement. 

merci !  Un peu la honte quand même !  Confused  Big Grin Big Grin Big Grin
Calaos v1.1.20 sur Advantech x86 | Calaos Home écran tactile RS232 | Wago 750-841 | DMX RGB LED
Calaos-OS v2.0 sur Advantech x86 | Clé USB
Squeezebox | Raspberry & Scripts maison
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)