extern crate hyper; extern crate core; use std::io::Read; use hyper::Client; use hyper::header::Connection; use hyper::header::Basic; use hyper::header::Headers; use core::str::FromStr; fn main() { // Create a client. let mut client = Client::new(); let auth = Basic::from_str("admin:admin").unwrap(); let mut res = client.post("https://admin:admin@bleaf1/command-api") // set a header .header(auth) .body(r#"{ "jsonrpc": "2.0", "method": "runCmds", "params": { "version": 1, "cmds": [ "show version" ], "format": "json", }, "id": "1" }"#) // let 'er go! .send().unwrap(); // Read the Response. let mut body = String::new(); res.read_to_string(&mut body).unwrap(); println!("Response: {}", body); }