Can't find method even though feature is in dependencies (reqwest)

    let client = reqwest::blocking::Client::new();
    let res = my_res!(client.post("https://removed")
        .form(&params)
        .body("the exact body that is sent")
        .danger_accept_invalid_certs(true)
        .send(), {
            return Err(String::from("failed send"));
    });

is producing compiler error: no method named danger_accept_invalid_certs found for struct reqwest::blocking::RequestBuilder in the current scope

The documentation states "Available on crate features default-tls or native-tls or rustls-tls only."

and thus my cargo.toml attempt is currently:

[dependencies]
native-tls = { version = "0.2.2", optional = true }
reqwest = { version = "0.11.11", features = ["native-tls-crate", "default-tls", "native-tls", "blocking"] }

but I cannot seem to find this method!

danger_accept_invalid_certs is a method on ClientBuilder which you linked to. The builder returned from client.post(...) is a RequestBuilder, as the error message notes.

In other words the setting is a property of the client, not the request. So you can't set it on an individual request.

3 Likes