Streamline management of API collections #1
@@ -113,11 +113,11 @@ function Parse-HttpBlock($text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return @{
|
return @{
|
||||||
method = $http.method
|
method = $http.method
|
||||||
url = $http.url
|
url = $http.url
|
||||||
params = $http.params
|
params = $http.params
|
||||||
headers = $headers
|
headers = $headers
|
||||||
body = $http.body
|
body = $http.body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,8 +238,17 @@ function Build-RequestContent($http, $name, $config, $dotenvVars) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($http.body) {
|
if ($http.body) {
|
||||||
$lines += ""
|
if ($http.body.type -eq 'json') {
|
||||||
$lines += ($http.body.data | ConvertTo-Json -Depth 10)
|
$lines += ""
|
||||||
|
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")
|
return ($lines -join "`n")
|
||||||
|
|||||||
Reference in New Issue
Block a user