i get the following error while creating this POST request. Im a newbie in RUST.
Instead of serde_json::Value
I have even tried HashMap<String, String>
still the same issue.
if you could tell me if my headers are wrong or how do I trace if its actually a network reqwest issue or not ?
This is the actual response Im expecting. Session
I have tried to replace serde_json::Value to Session still no effect the error persists.
#[derive(Debug, Deserialize, Serialize)]
pub struct Session {
pub platform_type: String,
pub ticket: String,
pub profile_id: String,
pub user_id: String,
pub name_on_platform: String,
pub expiration: String, //2020-08-26T16:46:59.4772040Z
}
I'm using Popos 20.04 and Rust 1.45.2
pub async fn login(&self) -> Result<serde_json::Value, reqwest::Error> {
let response = self.client
.post(request_url)
.headers(self.construct_headers())
.basic_auth(self.email.clone(), Some(self.password.clone()))
.send().await?
.json::<serde_json::Value>().await?;
Ok(response)
}
fn construct_headers(&self) -> HeaderMap {
let mut headers = HeaderMap::new();
headers.insert("ubi-appid", HeaderValue::from_str(self.ubi_config.appid.as_str()).unwrap());
headers.insert(USER_AGENT, HeaderValue::from_static("reqwest"));
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
headers
}
And this would just give me the following error:
reqwest::Error { kind: Decode, source: Error("expected value", line: 1, column: 1) }'
[dependencies]
serenity = "0.9.0-rc.0"
reqwest = "0.10.8"
tokio = { version = "0.2.22", features = ["full"] }
serde = {version = "1.0.114", features = ["derive"]}
serde_json = "1.0.57"
dotenv = "0.15.0"
config = "0.10.1"
Thank you.