I'm creating an application to get data from an API. Then I used reqwest. In this case, I need to send headers like below.
route.rs
#[get("/token")]
async fn get_token() -> String {
let set_token = common::auth_test();
return set_token;
}
comm.rs
extern crate reqwest;
use reqwest::header::Authorization;
use reqwest::header::ContentType;
pub fn auth_test() -> String {
let client = reqwest::Client::new();
let resz = client.post("https://api.have.test.com/auth/token")
.header(Authorization, "Basic abc456hghtyhg==")
.header(ContentType, "application/x-www-form-urlencoded")
.header(grant_type, "client_credentials")
.send();
return resz;
}
But, when I run the application, I got these below errors.
this comes under the header.
this function takes 1 parameter but 2 parameters were supplied
expected 1 parameterrustc(E0061)
This comes under the grant_type.
cannot find value
grant_type
in this scope
not found in this scoperustc(E0425)
How can I solve them and get the response ??