Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `-KeyColumn` to `Add-PnPDataRowsToSiteTemplate` which allows for overwriting existing list items in a site template [#2616](https://github.com/pnp/powershell/pull/2616)
- Added `Get-PnPFolderStorageMetric` which allows storage usage of a specific folder to be retrieved [#2646](https://github.com/pnp/powershell/pull/2646)
- Added `IsTeamsConnected`, `IsTeamsChannelConnected` and `TeamChannelType` to be returned when `Get-PnPTenantSite` cmdlet is executed. [#2656](https://github.com/pnp/powershell/pull/2656)
- Added `HTTP/2` support for all HTTP requests to improve performance for HTTP requests. [#2687](https://github.com/pnp/powershell/pull/2687)
- Added `-EnvironmentVariable` parameter to `Connect-PnPOnline` to connect using Azure environment variables. [#2681](https://github.com/pnp/powershell/pull/2681)
- Added `ResponseHeadersVariable` parameter to the `Invoke-PnPSPRestMethod` which if specified will store the response headers values in the PowerShell variable name that is specified. [#2711](https://github.com/pnp/powershell/pull/2711)
- Added `-Filter` parameter to `Get-PnPAzureADServicePrincipal` cmdlet to retrieve specific application registrations based on filter conditions. It supports simple and advanced queries. [#2710](https://github.com/pnp/powershell/pull/2710)
Expand Down
1 change: 1 addition & 0 deletions src/Commands/AzureAD/RegisterManagementShellAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ protected override void ProcessRecord()
var httpClient = Framework.Http.PnPHttpClient.Instance.GetHttpClient();
using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, $"https://{GetGraphEndPoint()}/v1.0/organization"))
{
requestMessage.Version = new System.Version(2, 0);
requestMessage.Headers.Add("Authorization", $"Bearer {accessToken}");
requestMessage.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
var response = httpClient.SendAsync(requestMessage).GetAwaiter().GetResult();
Expand Down
1 change: 1 addition & 0 deletions src/Commands/Base/InvokeSPRestMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected override void ExecuteCmdlet()
{
request.Headers.Add("IF-MATCH", "*");
}
request.Version = new Version(2, 0);

PnPHttpClient.AuthenticateRequestAsync(request, ClientContext).GetAwaiter().GetResult();

Expand Down
1 change: 1 addition & 0 deletions src/Commands/Base/TokenHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ internal static async Task<string> GetManagedIdentityTokenAsync(Cmdlet cmdlet, H

using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, tokenRequestUrl))
{
requestMessage.Version = new Version(2, 0);
requestMessage.Headers.Add("Metadata", "true");
if (!string.IsNullOrEmpty(identityHeader))
{
Expand Down
2 changes: 2 additions & 0 deletions src/Commands/PowerPlatform/PowerAutomate/ExportFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using PnP.PowerShell.Commands.Base;
using PnP.PowerShell.Commands.Base.PipeBinds;
using PnP.PowerShell.Commands.Utilities.REST;
using System;
using System.Management.Automation;
using System.Net.Http;
using System.Text.Json;
Expand Down Expand Up @@ -122,6 +123,7 @@ protected override void ExecuteCmdlet()
var packageLink = valueElement.GetString();
using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, packageLink))
{
requestMessage.Version = new Version(2, 0);
//requestMessage.Headers.Add("Authorization", $"Bearer {AccessToken}");
var response = Connection.HttpClient.SendAsync(requestMessage).GetAwaiter().GetResult();
var byteArray = response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
Expand Down
1 change: 1 addition & 0 deletions src/Commands/Utilities/BrowserHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ internal static bool GetWebBrowserPopup(string siteUrl, string title, (string ur

string requestUrl = string.Format("{0}/_api/contextinfo", siteUrl.TrimEnd('/'));
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUrl);
request.Version = new Version(2, 0);
request.Headers.Add("accept", "application/json;odata=nometadata");
HttpResponseMessage response = await httpClient.SendAsync(request);

Expand Down
1 change: 1 addition & 0 deletions src/Commands/Utilities/REST/GraphHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private static HttpRequestMessage GetMessage(string url, HttpMethod method, PnPC
}

var message = new HttpRequestMessage();
message.Version = new Version(2, 0);
message.Method = method;
message.Headers.TryAddWithoutValidation("Accept", "application/json");
message.RequestUri = !url.StartsWith("https://", StringComparison.OrdinalIgnoreCase) ? new Uri($"https://{connection.GraphEndPoint}/{url}") : new Uri(url);
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/Utilities/REST/RestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public static async Task<T> PatchAsync<T>(HttpClient httpClient, string url, str

public static async Task<string> PatchAsync(HttpClient httpClient, string url, string accessToken, object payload, string accept = "application/json")
{
HttpRequestMessage message = null;
HttpRequestMessage message = null;
if (payload != null)
{
#if NETFRAMEWORK
Expand Down Expand Up @@ -642,6 +642,7 @@ private static HttpRequestMessage GetMessage(string url, HttpMethod method, stri
}

var message = new HttpRequestMessage();
message.Version = new Version(2, 0);
message.Method = method;
message.RequestUri = new Uri(url);
if (!string.IsNullOrEmpty(accessToken))
Expand All @@ -665,6 +666,7 @@ private static HttpRequestMessage GetMessage(string url, HttpMethod method, Clie
}

var message = new HttpRequestMessage();
message.Version = new Version(2, 0);
message.Method = method;
message.RequestUri = new Uri(url);
message.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse(accept));
Expand Down
5 changes: 3 additions & 2 deletions src/Commands/Utilities/VersionChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ internal static string GetAvailableVersion(bool isNightly)

// Deliberately lowering timeout as the version check is not critical so in case of a slower or blocked internet connection, this should not block the cmdlet for too long
httpClient.Timeout = TimeSpan.FromSeconds(VersionCheckTimeOut);

var response = httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, isNightly ? NightlyVersionCheckUrl : ReleaseVersionCheckUrl)).GetAwaiter().GetResult();
var request = new HttpRequestMessage(HttpMethod.Get, isNightly ? NightlyVersionCheckUrl : ReleaseVersionCheckUrl);
request.Version = new Version(2, 0);
var response = httpClient.SendAsync(request).GetAwaiter().GetResult();
if (response.IsSuccessStatusCode)
{
var onlineVersion = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
Expand Down