diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e0482b..6d769b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Derive `Hash` on requests types. [#114](https://github.com/jeertmans/languagetool-rust/pull/114) - Use Codspeed and `check-changelog` actions. [#121](https://github.com/jeertmans/languagetool-rust/pull/121) +### Fixed + +- Fixed api calls to language tool server to adhere to spec. Pass POST calls as `application/x-www-form-urlencoded`. [#129](https://github.com/jeertmans/languagetool-rust/pull/129) + ## [2.1.4](https://github.com/jeertmans/languagetool-rust/compare/v2.1.3...v2.1.4) ### Fixed diff --git a/src/lib/server.rs b/src/lib/server.rs index 8c38b1b..bb37987 100644 --- a/src/lib/server.rs +++ b/src/lib/server.rs @@ -11,7 +11,7 @@ use crate::{ }; #[cfg(feature = "cli")] use clap::Args; -use reqwest::Client; +use reqwest::{header::{HeaderValue, ACCEPT}, Client}; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::{io, path::PathBuf, time::Instant}; @@ -372,7 +372,8 @@ impl ServerClient { match self .client .post(format!("{0}/check", self.api)) - .query(request) + .header(ACCEPT, HeaderValue::from_static("application/json")) + .form(request) .send() .await { @@ -485,6 +486,7 @@ impl ServerClient { match self .client .get(format!("{}/words", self.api)) + .header(ACCEPT, HeaderValue::from_static("application/json")) .query(request) .send() .await @@ -508,7 +510,8 @@ impl ServerClient { match self .client .post(format!("{}/words/add", self.api)) - .query(request) + .header(ACCEPT, HeaderValue::from_static("application/json")) + .form(request) .send() .await { @@ -531,7 +534,8 @@ impl ServerClient { match self .client .post(format!("{}/words/delete", self.api)) - .query(request) + .header(ACCEPT, HeaderValue::from_static("application/json")) + .form(request) .send() .await {