How to transfer JSON file

My target is to transfer a JSON file from a client to an http server using reqwest crate.
I am using the following sample. The good news is, it complies and is working. But in this code the JSON is a handcrafted file in the code, where as my target is to transfer/post an already available file ( from local machine file system) to the http server. How to achieve this please.

use error_chain::error_chain;
use std::collections::HashMap;

error_chain! {
foreign_links {

async fn main() -> Result<()> {
let mut map = HashMap::new();

map.insert("FirsName", "Syed");
map.insert("LastName", "Kamran");

let client = reqwest::Client::new();
let res ="")

let response_text = res.text().await?;
println!("Your paste is located at: {}",response_text );   


You may want to start by reading the filesystem library docs.

1 Like