Complete the code to send a GET request to the URL and store the response.
$response = Invoke-RestMethod -Uri [1]The -Uri parameter requires the URL string to send the GET request. Option A provides the correct URL string.
Complete the code to send a POST request with JSON data to the API.
Invoke-RestMethod -Uri "https://api.example.com/submit" -Method [1] -Body $jsonData -ContentType "application/json"
The -Method parameter specifies the HTTP method. To send data, POST is used.
Fix the error in the code to correctly add a custom header to the REST API request.
$headers = @{ "Authorization" = [1] }
Invoke-RestMethod -Uri "https://api.example.com/data" -Headers $headersThe header value must be a string, so it needs to be enclosed in quotes. Option B correctly uses double quotes.
Fill both blanks to create a REST API call that sends JSON data with a custom header.
$headers = @{ "Content-Type" = [1] }
Invoke-RestMethod -Uri "https://api.example.com/update" -Method [2] -Headers $headers -Body $jsonPayloadThe Content-Type header should be set to application/json when sending JSON data. The HTTP method to send data is POST.
Fill all three blanks to parse JSON response and extract a property value.
$response = Invoke-RestMethod -Uri "https://api.example.com/info" $value = $response.[1] if ($value -eq [2]) { Write-Output [3] }
The code extracts the status property from the JSON response. It checks if it equals the string "success", then outputs a message.