Skip to content

Commit 8bf099e

Browse files
rachelxj-msXuejun Li
andauthored
Fixed Set-AzPolicySetDefinition InternalServerError when the initiative is too large [#20238] (#20252)
Co-authored-by: Xuejun Li <[email protected]>
1 parent e6b15b4 commit 8bf099e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/Resources/ResourceManager/RestClients/ResourceManagerRestClientBase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.RestClients
1818
using System.Linq;
1919
using System.Net.Http;
2020
using System.Text;
21+
using System.Text.RegularExpressions;
2122
using System.Threading;
2223
using System.Threading.Tasks;
2324
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
@@ -163,6 +164,8 @@ protected async Task<HttpResponseMessage> SendRequestAsync(
163164
CancellationToken cancellationToken)
164165
{
165166
var contentString = content == null ? string.Empty : content.ToString();
167+
// minify JOSN payload to avoid payload too large error
168+
contentString = Regex.Replace(contentString, @"\r\n?|\n|\t| ", String.Empty);
166169
using (var httpContent = new StringContent(content: contentString, encoding: Encoding.UTF8, mediaType: "application/json"))
167170
using (var request = new HttpRequestMessage(method: httpMethod, requestUri: requestUri) { Content = httpContent })
168171
{

src/Resources/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
## Upcoming Release
2222
* Added cmdlet `Get-AzADOrganization`
23+
* Fixed `Set-AzPolicySetDefinition` InternalServerError when the initiative is too large [#20238]
2324

2425
## Version 6.4.1
2526
* Upgraded AutoMapper to Microsoft.Azure.PowerShell.AutoMapper 6.2.2 with fix [#18721]

0 commit comments

Comments
 (0)