From e6d2f2ce676b8bb13b48ca6cd76ac17fe84b0183 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Thu, 11 Jan 2024 10:23:01 +0300 Subject: [PATCH] Fixes missing parameter values on empty strings --- CHANGELOG.md | 6 ++++++ .../RequestInformationTests.cs | 3 ++- src/Microsoft.Kiota.Abstractions.csproj | 2 +- src/RequestInformation.cs | 1 - 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1588da65..1b78848f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.7.5] - 2024-01-11 + +### Changed + +- Fixes missing query parameters when the parameter values are empty strings.(https://github.com/microsoft/kiota-abstractions-dotnet/issues/172) + ## [1.7.4] - 2024-01-09 ### Changed diff --git a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs index df4cefb2..e2e1d872 100644 --- a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs +++ b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs @@ -87,8 +87,9 @@ public void DoesNotSetEmptyStringQueryParameters() requestInfo.AddQueryParameters(qParams); // Assert - Assert.False(requestInfo.QueryParameters.ContainsKey($"%24search")); + Assert.True(requestInfo.QueryParameters.ContainsKey($"%24search")); Assert.False(requestInfo.QueryParameters.ContainsKey("search")); + Assert.Equal("http://localhost/me?%24search=", requestInfo.URI.OriginalString); } [Fact] public void DoesNotSetEmptyCollectionQueryParameters() diff --git a/src/Microsoft.Kiota.Abstractions.csproj b/src/Microsoft.Kiota.Abstractions.csproj index b56d65f6..32330f26 100644 --- a/src/Microsoft.Kiota.Abstractions.csproj +++ b/src/Microsoft.Kiota.Abstractions.csproj @@ -14,7 +14,7 @@ https://aka.ms/kiota/docs true true - 1.7.4 + 1.7.5 true false diff --git a/src/RequestInformation.cs b/src/RequestInformation.cs index f8ab13ae..d4f5054a 100644 --- a/src/RequestInformation.cs +++ b/src/RequestInformation.cs @@ -168,7 +168,6 @@ public void AddQueryParameters(T source) ) .Where(x => x.Value != null && !QueryParameters.ContainsKey(x.Name!) && - !string.IsNullOrEmpty(x.Value.ToString()) && // no need to add an empty string value (x.Value is not ICollection collection || collection.Count > 0))) // no need to add empty collection { QueryParameters.AddOrReplace(property.Name!, property.Value!);