add warning message for unparseable JSON in body data

This commit is contained in:
2026-06-30 12:24:11 +02:00
parent 525d4f4cf0
commit 4caf0d855e
+10 -1
View File
@@ -238,8 +238,17 @@ function Build-RequestContent($http, $name, $config, $dotenvVars) {
}
if ($http.body) {
if ($http.body.type -eq 'json') {
$lines += ""
$lines += ($http.body.data | ConvertTo-Json -Depth 10)
try {
$lines += ($http.body.data | ConvertFrom-Json -Depth 10 | ConvertTo-Json -Depth 10)
}
catch {
<#Do this if a terminating exception happens#>
Write-Warning "Failed to parse JSON for request $name, will use original content"
$lines += $http.body.data
}
}
}
return ($lines -join "`n")