Only convert to json if response content is of json type (#6589)
Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
parent
7317d787a2
commit
a1aa57222f
@ -58,7 +58,6 @@ function Submit-Request($filePath, $packageName)
|
||||
|
||||
$correlationId = [System.Guid]::NewGuid().ToString()
|
||||
$headers = @{
|
||||
"Content-Type" = "application/json"
|
||||
"x-correlation-id" = $correlationId
|
||||
}
|
||||
LogInfo "Request URI: $($uri.Uri.OriginalString)"
|
||||
@ -67,8 +66,10 @@ function Submit-Request($filePath, $packageName)
|
||||
{
|
||||
$Response = Invoke-WebRequest -Method 'GET' -Uri $uri.Uri -Headers $headers -MaximumRetryCount 3
|
||||
$StatusCode = $Response.StatusCode
|
||||
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
|
||||
LogSuccess $responseContent
|
||||
if ($Response.Headers['Content-Type'] -like 'application/json*') {
|
||||
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
|
||||
LogSuccess $responseContent
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@ -267,7 +267,6 @@ function Create-API-Review {
|
||||
$correlationId = [System.Guid]::NewGuid().ToString()
|
||||
|
||||
$headers = @{
|
||||
"Content-Type" = "application/json"
|
||||
"x-correlation-id" = $correlationId
|
||||
}
|
||||
|
||||
@ -277,13 +276,20 @@ function Create-API-Review {
|
||||
try
|
||||
{
|
||||
$response = Invoke-WebRequest -Method 'GET' -Uri $requestUri.Uri -Headers $headers -MaximumRetryCount 3
|
||||
if ($response.StatusCode -eq 201) {
|
||||
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
|
||||
LogSuccess "Status Code: $($response.StatusCode)`nAPI review request created successfully.`n$($responseContent)"
|
||||
}
|
||||
elseif ($response.StatusCode -eq 208) {
|
||||
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
|
||||
LogSuccess "Status Code: $($response.StatusCode)`nThere is no API change compared with the previous version.`n$($responseContent)"
|
||||
if ($response.StatusCode -eq 201 -or $response.StatusCode -eq 208) {
|
||||
if ($response.StatusCode -eq 201) {
|
||||
LogSuccess "Status Code: $($response.StatusCode)`nAPI review request created successfully"
|
||||
}
|
||||
elseif ($response.StatusCode -eq 208) {
|
||||
LogSuccess "Status Code: $($response.StatusCode)`nThere is no API change compared with the previous version."
|
||||
}
|
||||
if ($response.Headers['Content-Type'] -like 'application/json*') {
|
||||
$responseContent = $response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
|
||||
LogSuccess "Response:`n$($responseContent)"
|
||||
}
|
||||
else {
|
||||
LogSuccess "Response: $($response.Content)"
|
||||
}
|
||||
}
|
||||
else {
|
||||
LogError "Failed to create API review request. $($response)"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user