test-cloudfunc3.ps1 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Test cloud functions - get detailed error info
  2. $ct = "application/json"
  3. # Test 1: getApigInfo without _ApplicationId
  4. Write-Host "=== Test 1: No AppId ===" -ForegroundColor Cyan
  5. try {
  6. $body = '{"apigId":"Vo3ROWEvDy"}'
  7. $r = Invoke-WebRequest -Uri "https://server.fmode.cn/parse/functions/t012qy4XVe" -Method POST -ContentType $ct -Body $body -TimeoutSec 10
  8. Write-Host "Status: $($r.StatusCode) Body: $($r.Content)"
  9. } catch {
  10. if ($_.Exception.Response) {
  11. $stream = $_.Exception.Response.GetResponseStream()
  12. $reader = New-Object System.IO.StreamReader($stream)
  13. Write-Host "Status: $($_.Exception.Response.StatusCode) Body: $($reader.ReadToEnd())" -ForegroundColor Yellow
  14. } else { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }
  15. }
  16. Write-Host ""
  17. # Test 2: With _ApplicationId in body
  18. Write-Host "=== Test 2: AppId in body ===" -ForegroundColor Cyan
  19. try {
  20. $body = '{"_ApplicationId":"ncloudmaster","apigId":"Vo3ROWEvDy"}'
  21. $r = Invoke-WebRequest -Uri "https://server.fmode.cn/parse/functions/t012qy4XVe" -Method POST -ContentType $ct -Body $body -TimeoutSec 10
  22. Write-Host "Status: $($r.StatusCode) Body: $($r.Content)"
  23. } catch {
  24. if ($_.Exception.Response) {
  25. $stream = $_.Exception.Response.GetResponseStream()
  26. $reader = New-Object System.IO.StreamReader($stream)
  27. Write-Host "Status: $($_.Exception.Response.StatusCode) Body: $($reader.ReadToEnd())" -ForegroundColor Yellow
  28. } else { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }
  29. }
  30. Write-Host ""
  31. # Test 3: With X-Parse-Application-Id header
  32. Write-Host "=== Test 3: AppId in header ===" -ForegroundColor Cyan
  33. try {
  34. $headers = @{ "X-Parse-Application-Id" = "ncloudmaster"; "Content-Type" = $ct }
  35. $body = '{"apigId":"Vo3ROWEvDy"}'
  36. $r = Invoke-WebRequest -Uri "https://server.fmode.cn/parse/functions/t012qy4XVe" -Method POST -Headers $headers -Body $body -TimeoutSec 10
  37. Write-Host "Status: $($r.StatusCode) Body: $($r.Content)"
  38. } catch {
  39. if ($_.Exception.Response) {
  40. $stream = $_.Exception.Response.GetResponseStream()
  41. $reader = New-Object System.IO.StreamReader($stream)
  42. Write-Host "Status: $($_.Exception.Response.StatusCode) Body: $($reader.ReadToEnd())" -ForegroundColor Yellow
  43. } else { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }
  44. }
  45. Write-Host ""
  46. # Test 4: Same as pay_code2 pattern (which works in the page)
  47. Write-Host "=== Test 4: pay_code2 pattern (reference) ===" -ForegroundColor Cyan
  48. try {
  49. $body = '{"trade_no":"TEST123","total_fee":0.01,"body":"test","company":"1AiWpTEDH9"}'
  50. $r = Invoke-WebRequest -Uri "https://server.fmode.cn/parse/functions/pay_code2" -Method POST -ContentType $ct -Body $body -TimeoutSec 10
  51. Write-Host "Status: $($r.StatusCode) Body: $($r.Content.Substring(0,200))" -ForegroundColor Green
  52. } catch {
  53. if ($_.Exception.Response) {
  54. $stream = $_.Exception.Response.GetResponseStream()
  55. $reader = New-Object System.IO.StreamReader($stream)
  56. Write-Host "Status: $($_.Exception.Response.StatusCode) Body: $($reader.ReadToEnd())" -ForegroundColor Yellow
  57. } else { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }
  58. }