diff --git a/influxdb2_client/src/api/buckets.rs b/influxdb2_client/src/api/buckets.rs index 1e2b287ef5..37f812a610 100644 --- a/influxdb2_client/src/api/buckets.rs +++ b/influxdb2_client/src/api/buckets.rs @@ -16,6 +16,7 @@ impl Client { let response = self .request(Method::POST, &create_bucket_url) + .header("Content-Type", "application/json") .body( serde_json::to_string(&post_bucket_request.unwrap_or_default()) .context(SerializingSnafu)?, @@ -47,6 +48,7 @@ mod tests { let mock_server = mock("POST", "/api/v2/buckets") .match_header("Authorization", format!("Token {}", token).as_str()) + .match_header("Content-Type", "application/json") .match_body( format!( r#"{{"orgID":"{}","name":"{}","retentionRules":[]}}"#, diff --git a/influxdb2_client/src/api/label.rs b/influxdb2_client/src/api/label.rs index fe59f68c49..bb98256caa 100644 --- a/influxdb2_client/src/api/label.rs +++ b/influxdb2_client/src/api/label.rs @@ -73,6 +73,7 @@ impl Client { }; let response = self .request(Method::POST, &create_label_url) + .header("Content-Type", "application/json") .body(serde_json::to_string(&body).context(SerializingSnafu)?) .send() .await @@ -100,6 +101,7 @@ impl Client { let body = LabelUpdate { name, properties }; let response = self .request(Method::PATCH, &update_label_url) + .header("Content-Type", "application/json") .body(serde_json::to_string(&body).context(SerializingSnafu)?) .send() .await @@ -198,6 +200,7 @@ mod tests { let mock_server = mock("POST", BASE_PATH) .match_header("Authorization", format!("Token {}", token).as_str()) + .match_header("Content-Type", "application/json") .match_body( format!( r#"{{"orgID":"{}","name":"{}","properties":{{"some-key":"some-value"}}}}"#, @@ -222,6 +225,7 @@ mod tests { let mock_server = mock("POST", BASE_PATH) .match_header("Authorization", format!("Token {}", token).as_str()) + .match_header("Content-Type", "application/json") .match_body(format!(r#"{{"orgID":"{}","name":"{}"}}"#, org_id, name).as_str()) .create(); @@ -242,6 +246,7 @@ mod tests { let mock_server = mock("PATCH", format!("{}/{}", BASE_PATH, label_id).as_str()) .match_header("Authorization", format!("Token {}", token).as_str()) + .match_header("Content-Type", "application/json") .match_body( format!( r#"{{"name":"{}","properties":{{"some-key":"some-value"}}}}"#, @@ -267,6 +272,7 @@ mod tests { let mock_server = mock("PATCH", format!("{}/{}", BASE_PATH, label_id).as_str()) .match_header("Authorization", format!("Token {}", token).as_str()) + .match_header("Content-Type", "application/json") .match_body("{}") .create(); diff --git a/influxdb2_client/src/api/setup.rs b/influxdb2_client/src/api/setup.rs index 4d4c3cc661..4b04cae280 100644 --- a/influxdb2_client/src/api/setup.rs +++ b/influxdb2_client/src/api/setup.rs @@ -54,6 +54,7 @@ impl Client { let response = self .request(Method::POST, &setup_init_url) + .header("Content-Type", "application/json") .body(serde_json::to_string(&body).context(SerializingSnafu)?) .send() .await @@ -94,6 +95,7 @@ impl Client { let response = self .request(Method::POST, &setup_new_url) + .header("Content-Type", "application/json") .body(serde_json::to_string(&body).context(SerializingSnafu)?) .send() .await @@ -138,6 +140,7 @@ mod tests { let retention_period_hrs = 1; let mock_server = mock("POST", "/api/v2/setup") + .match_header("Content-Type", "application/json") .match_body( format!( r#"{{"username":"{}","org":"{}","bucket":"{}","password":"{}","retentionPeriodHrs":{}}}"#, @@ -173,6 +176,7 @@ mod tests { let mock_server = mock("POST", "/api/v2/setup/user") .match_header("Authorization", format!("Token {}", token).as_str()) + .match_header("Content-Type", "application/json") .match_body( format!( r#"{{"username":"{}","org":"{}","bucket":"{}","password":"{}","retentionPeriodHrs":{}}}"#, @@ -204,6 +208,7 @@ mod tests { let bucket = "some-bucket"; let mock_server = mock("POST", "/api/v2/setup") + .match_header("Content-Type", "application/json") .match_body( format!( r#"{{"username":"{}","org":"{}","bucket":"{}"}}"#, @@ -231,6 +236,7 @@ mod tests { let mock_server = mock("POST", "/api/v2/setup/user") .match_header("Authorization", format!("Token {}", token).as_str()) + .match_header("Content-Type", "application/json") .match_body( format!( r#"{{"username":"{}","org":"{}","bucket":"{}"}}"#,