diff --git a/CHANGELOG.md b/CHANGELOG.md index 1becc58c7..19295aaff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `Add-PnPTeamsChannelUser` which allows members and owners to be added to private channels in Teams [#1735](https://github.com/pnp/powershell/pull/1735) - Added `ExcludeVisualPromotedResults` parameter to `Get-PnPSearchConfiguration` which excludes promoted results [#1750](https://github.com/pnp/powershell/pull/1750) - Added `MediaTranscription` parameter to `Set-PnPTenantSite` and `Set-PnPSite` cmdlets which when enabled allows videos to have transcripts generated on demand or generated automatically in certain scenarios +- Added `Accept` parameter to `Invoke-PnPSPRestMethod` cmdlet which if specified will pass the Accept HTTP request header. ### Changed - Changed `Sync-PnPSharePointUserProfilesFromAzureActiveDirectory` to map users based on their Ids instead which should resolve some issues around user identities reporting not to exist. You can use the new `-IdType` option to switch it back to `PrincipalName` if needed. [#1752](https://github.com/pnp/powershell/pull/1752) diff --git a/documentation/Invoke-PnPSPRestMethod.md b/documentation/Invoke-PnPSPRestMethod.md index 593029f67..177437ecd 100644 --- a/documentation/Invoke-PnPSPRestMethod.md +++ b/documentation/Invoke-PnPSPRestMethod.md @@ -128,6 +128,18 @@ Position: 0 Accept pipeline input: False ``` +### -Accept +The Accept HTTP request header. Defaults to 'application/json;odata=nometadata'. + +```yaml +Type: String +Parameter Sets: (All) + +Required: False +Position: Named +Accept pipeline input: False +``` + ### -Connection Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. diff --git a/src/Commands/Base/InvokeSPRestMethod.cs b/src/Commands/Base/InvokeSPRestMethod.cs index 87a3f7917..85885ad09 100644 --- a/src/Commands/Base/InvokeSPRestMethod.cs +++ b/src/Commands/Base/InvokeSPRestMethod.cs @@ -33,6 +33,9 @@ public class InvokeSPRestMethod : PnPSharePointCmdlet [Parameter(Mandatory = false)] public string ContentType = "application/json"; + [Parameter(Mandatory = false)] + public string Accept = "application/json;odata=nometadata"; + [Parameter(Mandatory = false)] public SwitchParameter Raw; @@ -52,7 +55,12 @@ protected override void ExecuteCmdlet() using (HttpRequestMessage request = new HttpRequestMessage(method, requestUrl)) { - request.Headers.Add("accept", "application/json;odata=nometadata"); + if(string.IsNullOrEmpty(Accept)) + { + Accept = "application/json;odata=nometadata"; + } + + request.Headers.Add("accept", Accept); if (Method == HttpRequestMethod.Merge) {