-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api.ps1
More file actions
53 lines (45 loc) · 1.56 KB
/
Copy pathtest_api.ps1
File metadata and controls
53 lines (45 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# PowerShell script to test the survey response submission API
# Wait for the server to start
Write-Host "Waiting for server to start..."
Start-Sleep -Seconds 5
# Submit a survey response
Write-Host "Submitting survey response..."
$response1 = Invoke-RestMethod -Uri "http://localhost:8080/api/survey/submit" `
-Method Post `
-ContentType "application/json" `
-Body '{
"survey_id": "survey123",
"answers": {
"question1": "answer1",
"question2": "answer2",
"question3": "answer3"
}
}'
Write-Host "Response: $($response1 | ConvertTo-Json)"
Write-Host "`nSubmitting another response for the same survey (should be debounced)..."
$response2 = Invoke-RestMethod -Uri "http://localhost:8080/api/survey/submit" `
-Method Post `
-ContentType "application/json" `
-Body '{
"survey_id": "survey123",
"answers": {
"question1": "different answer",
"question2": "different answer",
"question3": "different answer"
}
}'
Write-Host "Response: $($response2 | ConvertTo-Json)"
Write-Host "`nSubmitting response for a different survey..."
$response3 = Invoke-RestMethod -Uri "http://localhost:8080/api/survey/submit" `
-Method Post `
-ContentType "application/json" `
-Body '{
"survey_id": "survey456",
"answers": {
"question1": "answer1",
"question2": "answer2",
"question3": "answer3"
}
}'
Write-Host "Response: $($response3 | ConvertTo-Json)"
Write-Host "`nTest completed."