|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add-type @"
|
|
|
using System.Net;
|
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
public class TrustAllCertsPolicy : ICertificatePolicy {
|
|
|
public bool CheckValidationResult(
|
|
|
ServicePoint srvPoint, X509Certificate certificate,
|
|
|
WebRequest request, int certificateProblem) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
"@
|
|
|
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
|
|
|
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls13
|
|
|
|
|
|
|
|
|
$apiUrl = "http://localhost:8000/demo"
|
|
|
$email = "test@example.com"
|
|
|
$secret = "default_secret_change_me"
|
|
|
$quizUrl = "https://tds-llm-analysis.s-anand.net/project2"
|
|
|
|
|
|
|
|
|
$body = @{
|
|
|
email = $email
|
|
|
secret = $secret
|
|
|
url = $quizUrl
|
|
|
} | ConvertTo-Json
|
|
|
|
|
|
|
|
|
try {
|
|
|
Write-Host "Calling API: $apiUrl" -ForegroundColor Cyan
|
|
|
Write-Host "Request body:" -ForegroundColor Yellow
|
|
|
Write-Host $body -ForegroundColor Gray
|
|
|
|
|
|
$response = Invoke-RestMethod `
|
|
|
-Uri $apiUrl `
|
|
|
-Method POST `
|
|
|
-ContentType "application/json" `
|
|
|
-Body $body
|
|
|
|
|
|
Write-Host "`nResponse:" -ForegroundColor Green
|
|
|
$response | ConvertTo-Json -Depth 10 | Write-Host -ForegroundColor White
|
|
|
} catch {
|
|
|
Write-Host "`nError occurred:" -ForegroundColor Red
|
|
|
Write-Host $_.Exception.Message -ForegroundColor Red
|
|
|
if ($_.ErrorDetails.Message) {
|
|
|
Write-Host "Details:" -ForegroundColor Yellow
|
|
|
Write-Host $_.ErrorDetails.Message -ForegroundColor Gray
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|