# Define your YouTube API key and a test channel ID $youtubeApiKey = "AIzaSyAw6-9hHTAVh_2HI_iqIy2HOBh6gXcFbXs" # Replace with the actual API key $channelId = "UC_gUM8rL-Lrg6O3adPW9K1g" # Example channel ID for testing # Define the endpoint and parameters $endpoint = "https://www.googleapis.com/youtube/v3/search" $params = @{ part = "snippet" channelId = $channelId type = "video" eventType = "live" maxResults = 1 key = $youtubeApiKey } # Construct the query string manually and prepend the endpoint $queryString = ($params.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join "&" $fullUrl = "${endpoint}?${queryString}" # Output the full URL for debugging Write-Output "Full URL: $fullUrl" try { # Send the request $response = Invoke-RestMethod -Uri $fullUrl -Method Get Write-Output "YouTube API Response Items:" Write-Output $response.items | Format-List } catch { Write-Output "YouTube API Error: " + $_.Exception.Message }