We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to make post request using reqwest crate of rust. Here is the snippet of cargo.toml
[dependencies] tokio = { version = "0.2", features = ["full"] } reqwest = { version = "0.10", features = ["json"] }
Here is the snippet of code from which I am making request to simple server.
use reqwest::{Response, StatusCode}; use serde_json::{json, Value}; #[tokio::main] async fn main() -> Result< (), reqwest::Error> { let map1 = json!({ "abc":"abc", "efg":"efg" }); let body: Value = reqwest::Client::new() .post("http://localhost:4000/hello") .json(&map1) .send() .await? .json() .await?; println!("Data is : {:?}", body); Ok(()) }
The snippet of the code written using simple server crate from which I am serving this request is below:
use simple_server::{Server, StatusCode}; fn main() { let server = Server::new(|req, mut response| { println!( "Request received {} {} {:?}", req.method(), req.uri(), &req.body() ); match (req.method().as_str(), req.uri().path()) { ("GET", "/") => Ok(response.body(format!("Get request").into_bytes())?), ("POST", "/hello") => Ok(response.body(format!("Post request").into_bytes())?), (_, _) => { response.status(StatusCode::NOT_FOUND); Ok(response.body(String::from("Not Found").into_bytes())?) } } }); server.listen("127.0.0.1", "4000"); }
The output I get is :
Request received POST /hello []
The desired output is the vector array of bytes but I am receiving the empty vector array.
The solutions which I have already tried are:
So I think the issue must be with this simple server crate. Every worthy suggestion will be Encouraged.
The text was updated successfully, but these errors were encountered:
same issue
Sorry, something went wrong.
No branches or pull requests
I am trying to make post request using reqwest crate of rust. Here is the snippet of cargo.toml
Here is the snippet of code from which I am making request to simple server.
The snippet of the code written using simple server crate from which I am serving this request is below:
The output I get is :
The desired output is the vector array of bytes but I am receiving the empty vector array.
The solutions which I have already tried are:
So I think the issue must be with this simple server crate.
Every worthy suggestion will be Encouraged.
The text was updated successfully, but these errors were encountered: