expression

Specify acceptable response media types

Accept describes what response representations a client prefers. It is not a guarantee of the returned content type or schema. Validate the response before decoding. External crate example; constructs requests or synthetic responses in memory; no request is sent. Expected stdout (not executed): application/json Common mistake: Confusing Accept with the request body Content-Type.

Formal Syntax & Structure

rust syntaxrust
builder.header(reqwest::header::ACCEPT, value)

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() {    let c = reqwest::Client::builder().no_proxy().build().unwrap();    let r = c.get("https://example.com/books").header(reqwest::header::ACCEPT,"application/json").build().unwrap();    println!("{}", r.headers()[reqwest::header::ACCEPT].to_str().unwrap());}
Rust Reference