Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1723 - added Accept header as parameter #1795

Merged
merged 1 commit into from
Apr 28, 2022
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 @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions documentation/Invoke-PnPSPRestMethod.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
10 changes: 9 additions & 1 deletion src/Commands/Base/InvokeSPRestMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
{
Expand Down