From 78a4acf72cf71931be75dfa5cb61a6bf26c6c48c Mon Sep 17 00:00:00 2001 From: Bert Jansen Date: Thu, 3 Feb 2022 16:49:50 +0100 Subject: [PATCH] Hit client.svc on the root site collection to avoid being redirected there --- src/sdk/PnP.Core/Services/Core/PnPContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sdk/PnP.Core/Services/Core/PnPContext.cs b/src/sdk/PnP.Core/Services/Core/PnPContext.cs index 10c1636b00..6f0517cfca 100644 --- a/src/sdk/PnP.Core/Services/Core/PnPContext.cs +++ b/src/sdk/PnP.Core/Services/Core/PnPContext.cs @@ -808,7 +808,8 @@ internal async Task SetAADTenantId() { if (GlobalOptions.AADTenantId == Guid.Empty && Uri != null) { - using (var request = new HttpRequestMessage(HttpMethod.Get, $"{Uri}/_vti_bin/client.svc")) + // Hit client.svc on the root site collection to avoid being redirected there + using (var request = new HttpRequestMessage(HttpMethod.Get, $"{Uri.Scheme }://{Uri.DnsSafeHost}/_vti_bin/client.svc")) { request.Headers.Add("Authorization", "Bearer"); HttpResponseMessage response = await httpClient.SendAsync(request).ConfigureAwait(false);