powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[FEATURE] Add ability to use batch API with Invoke-PnPSPRestMethod

Open joerodgers opened this issue 3 years ago • 2 comments

Category

  • [x] Feature request

Describe the feature

Add ability to use batch API with Invoke-PnPSPRestMethod

Describe the solution you'd like

$batch = New-PnPBatch

Invoke-PnPSPRestMethod -Method Get -Url "/_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/sites('e8ef6ff7-220f-49d4-bd21-739bc66540c2')" -Batch
Invoke-PnPSPRestMethod -Method Get -Url "/_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/sites('3975956e-2a3a-43eb-8312-3833fb523874')" -Batch
Invoke-PnPSPRestMethod -Method Get -Url "/_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/sites('3ecc13a9-a83f-4403-8870-f5417e95b60c')" -Batch
Invoke-PnPSPRestMethod -Method Get -Url "/_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/sites('5459a6c1-f748-4737-bc52-6b66bbf53cf2')" -Batch

Invoke-PnPBatch -Batch $batch

joerodgers avatar Feb 22 '22 16:02 joerodgers

Good feature request @joerodgers. Given this means updating PnP PowerShell I'll move this issue to the PnP PS repo.

jansenbe avatar Feb 23 '22 07:02 jansenbe

Invoke-PnPSPRestMethod automatically adds the header "accept", "application/json;odata=nometadata" which causes any /_api/$batch responses to not include any response details. This header value will need remove the odata=nometadata option to allow Invoke-PnPSPRestMethod to be used to call the $batch endpoint.

https://github.com/pnp/powershell/blob/cda794b5292576d4049158223c401d163f428b3d/src/Commands/Base/InvokeSPRestMethod.cs#L55

joerodgers avatar Feb 23 '22 18:02 joerodgers

Has there been any update on this?

farhannsm avatar May 04 '23 21:05 farhannsm