diff --git a/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj b/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj
index b187cfffcd..c385a4f63a 100644
--- a/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj
+++ b/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj
@@ -4,7 +4,7 @@
9.0
netstandard2.0;net6.0;net472
Microsoft.Graph.PowerShell.Authentication.Core
- 2.6.1
+ 2.18.0
true
@@ -12,7 +12,7 @@
-
+
diff --git a/src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs b/src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs
index 5804251062..86ebdad20c 100644
--- a/src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs
+++ b/src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs
@@ -402,8 +402,7 @@ private Uri PrepareUri(HttpClient httpClient, Uri uri)
// set body to null to prevent later FillRequestStream
Body = null;
}
- // TODO: Review the fix made in https://github.com/microsoftgraph/msgraph-sdk-powershell/pull/2455.
- return uriBuilder.Uri;
+ return uriBuilder.Uri.EscapeDataStrings();
}
private void ThrowIfError(ErrorRecord error)
diff --git a/src/Authentication/Authentication/Helpers/EncodeUriPath.cs b/src/Authentication/Authentication/Helpers/EncodeUriPath.cs
index 72d8790a19..f16020f6b7 100644
--- a/src/Authentication/Authentication/Helpers/EncodeUriPath.cs
+++ b/src/Authentication/Authentication/Helpers/EncodeUriPath.cs
@@ -18,13 +18,25 @@ public static Uri EscapeDataStrings(this Uri uri)
int counter = 0;
var pathSegments = uri.OriginalString.Split('/');
StringBuilder sb = new StringBuilder();
- foreach (var segment in pathSegments)
+ foreach (var s in pathSegments)
{
+ var segment = s;
//Skips the left part of the uri i.e https://graph.microsoft.com
if (counter > 2)
{
sb.Append('/');
- sb.Append(Uri.EscapeDataString(segment));
+ if(s.Contains("?"))
+ {
+ var queryStringIndex = segment.IndexOf("?");
+ string queryString = segment.Substring(queryStringIndex);
+ segment = s.Substring(0, queryStringIndex);
+ sb.Append(Uri.EscapeDataString(segment));
+ sb.Append(queryString);
+ }
+ else
+ {
+ sb.Append(Uri.EscapeDataString(segment));
+ }
}
counter++;
}