I'm using reqwest dependency to call an API. But, when I used normal get API call, it gives me the successful response. But, when I use post API call with headers, it keep telling me there are errors with .header.
Here is the error.
this function takes 1 parameter but 2 parameters were supplied
expected 1 parameterrustc(E0061)
Here is the code.
extern crate reqwest;
use reqwest::header::Authorization;
use reqwest::header::ContentType;
pub fn authenticate() -> String {
let res = reqwest::get("http://api.github.com/users")
.expect("Couldnt")
.text().expect("no res");
let client = reqwest::Client::new();
let resz = client.post("https://api.test.com/auth/token")
.header(Authorization, "Basic abgtyhjmkiuyhjnmjhyuik==")
.header(ContentType, "application/x-www-form-urlencoded")
.body("grant_type=client_credentials")
.send();
return res;
}
You're probably using an older version of reqwest. In 0.8, the header method accepted 1 argument (see docs), but that API was changed in later versions.