Posted to tcl by aspect at Fri Feb 12 05:41:45 GMT 2016view raw
- package require http
- package require tls
- ::http::register https 443 tls:socket
- proc tls:socket args {
- set opts [lrange $args 0 end-2]
- set host [lindex $args end-1]
- set port [lindex $args end]
- ::tls::socket -ssl3 false -ssl2 false -tls1 true -servername $host {*}$opts $host $port
- }
- set json {{"authToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZGVudGl0eUlEIjoidXMtZWFzdC0xOmM0MDE3M2IxLTljODMtNGVkYy1hZWZlLTM1YTY5MzU2ZjM5NSIsInN5c3RlbUlEIjoiMDA6MUY6Qjg6MTI6MDU6MzEiLCJ0b2tlbkV4cGlyZXMiOjE0NTU4NDM0ODkxMDV9.20J4BOAx2a7Jdw_gA1MNhal36b7Ig02w2hvcdKLsUjY","localTimestamp":1455253722878,"message":"Hello From URC","category":"Hello, Dash","type":"success","from":"System Monitor"}}
- try {
- set token [::http::geturl "https://napier.digitalsmarties.com/v1/system/log" \
- -method POST \
- -query $json
- ]
- } on error {result options} {
- puts "\n\nError!\n---\n$result\n$options\n----\n\n"
- }
- puts [http::data $token]