diff --git a/src/main.rs b/src/main.rs index 051656e..526041c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,9 @@ static OWNER: Lazy = Lazy::new(|| { UserId::new(env::var("TELEGRAM_USER_ID").expect("TELEGRAM_USER_ID not set").parse().expect("TELEGRAM_USER_ID not numeric")) }); -static CLIENT: Lazy = Lazy::new(Client::new); +static CLIENT: Lazy = Lazy::new(|| { + Client::builder().http1_title_case_headers().build().unwrap() +}); #[tokio::main] async fn main() -> Result<(), Error> { @@ -229,11 +231,13 @@ async fn create_text_note(client: &Client, trilium_token: &str, title: &str, con // curl 'http://localhost:9001/api/clipper/notes' // -H 'Accept: */*' -H 'Accept-Language: en' --compressed -H 'Content-Type: application/json' // -H 'Authorization: icB3xohFDpkVt7YFpbTflUYC8pucmryVGpb1DFpd6ns=' + // -H 'trilium-local-now-datetime: 2020-05-29 __:__:__.xxx+__:__' // -H 'Origin: moz-extension://13bc3fd7-5cb0-4d48-b368-76e389fd7c5f' // --data '{"title":"line 1","content":"

line 2

line 3

","clipType":"note"}' - + let now = Local::now(); client.post("http://localhost:9001/api/clipper/notes") .header("Authorization", trilium_token) + .header("trilium-local-now-datetime", now.format("%Y-%m-%d %H:%M:%S%.3f%:z").to_string()) .json(&hashmap!{ "title" => title, "content" => content, "clipType" => "note" }) .send().await?; Ok(())