test-apig-routes.ps1 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # Test alternative API routes for getting APIG data
  2. $ct = @{ "Content-Type" = "application/json" }
  3. $id = "Vo3ROWEvDy"
  4. # Try different REST route patterns
  5. $routes = @(
  6. @{ url = "https://server.fmode.cn/api/apig/getApigById"; body = @{ objectId = $id } },
  7. @{ url = "https://server.fmode.cn/api/apig/detail"; body = @{ id = $id } },
  8. @{ url = "https://server.fmode.cn/api/apig/info"; body = @{ id = $id } },
  9. @{ url = "https://server.fmode.cn/api/apig/get"; body = @{ id = $id } },
  10. @{ url = "https://server.fmode.cn/api/apig/getApig"; body = @{ authid = $id; apigId = $id } }
  11. )
  12. foreach ($r in $routes) {
  13. Write-Host "=== $($r.url) ===" -ForegroundColor Cyan
  14. $jsonBody = $r.body | ConvertTo-Json -Compress
  15. try {
  16. $resp = Invoke-RestMethod -Uri $r.url -Method POST -Headers $ct -Body $jsonBody -TimeoutSec 8
  17. Write-Host "OK:" ($resp | ConvertTo-Json -Depth 3 -Compress) -ForegroundColor Green
  18. } catch {
  19. $code = ""
  20. if ($_.Exception.Response) { $code = $_.Exception.Response.StatusCode }
  21. Write-Host "Error: $code $($_.Exception.Message)" -ForegroundColor Red
  22. }
  23. Write-Host ""
  24. }
  25. # Also list API routes by requesting root
  26. Write-Host "=== Try /api/apig ===" -ForegroundColor Cyan
  27. try {
  28. $resp = Invoke-WebRequest -Uri "https://server.fmode.cn/api/apig" -Method GET -TimeoutSec 8
  29. Write-Host "Status:" $resp.StatusCode
  30. Write-Host $resp.Content.Substring(0, [Math]::Min(500, $resp.Content.Length))
  31. } catch {
  32. Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
  33. }