test-apig-cloudfunction.ps1 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Test different cloud function approaches to get APIG data
  2. $headers = @{ "Content-Type" = "application/json" }
  3. $appId = "ncloudmaster"
  4. # Try 1: getApig with id field
  5. Write-Host "=== Try getApig with id ===" -ForegroundColor Cyan
  6. try {
  7. $body = @{ id = "Vo3ROWEvDy" } | ConvertTo-Json -Compress
  8. $r = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/getApig" -Method POST -Headers $headers -Body $body -TimeoutSec 10
  9. Write-Host ($r | ConvertTo-Json -Depth 5)
  10. } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }
  11. Write-Host ""
  12. # Try 2: getApig with apigId
  13. Write-Host "=== Try getApig with apigId ===" -ForegroundColor Cyan
  14. try {
  15. $body = @{ apigId = "Vo3ROWEvDy" } | ConvertTo-Json -Compress
  16. $r = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/getApig" -Method POST -Headers $headers -Body $body -TimeoutSec 10
  17. Write-Host ($r | ConvertTo-Json -Depth 5)
  18. } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }
  19. Write-Host ""
  20. # Try 3: getApig with objectId
  21. Write-Host "=== Try getApig with objectId ===" -ForegroundColor Cyan
  22. try {
  23. $body = @{ objectId = "Vo3ROWEvDy" } | ConvertTo-Json -Compress
  24. $r = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/getApig" -Method POST -Headers $headers -Body $body -TimeoutSec 10
  25. Write-Host ($r | ConvertTo-Json -Depth 5)
  26. } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }
  27. Write-Host ""
  28. # Try 4: Cloud function approach
  29. Write-Host "=== Try cloud function getApig ===" -ForegroundColor Cyan
  30. try {
  31. $body = @{ _ApplicationId = $appId; objectId = "Vo3ROWEvDy"; className = "APIG" } | ConvertTo-Json -Compress
  32. $r = Invoke-RestMethod -Uri "https://server.fmode.cn/parse/functions/getApig" -Method POST -Headers $headers -Body $body -TimeoutSec 10
  33. Write-Host ($r | ConvertTo-Json -Depth 5)
  34. } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }
  35. Write-Host ""
  36. # Try 5: Generic getObject cloud function
  37. Write-Host "=== Try cloud function getObject ===" -ForegroundColor Cyan
  38. try {
  39. $body = @{ _ApplicationId = $appId; className = "APIG"; objectId = "Vo3ROWEvDy" } | ConvertTo-Json -Compress
  40. $r = Invoke-RestMethod -Uri "https://server.fmode.cn/parse/functions/getObject" -Method POST -Headers $headers -Body $body -TimeoutSec 10
  41. Write-Host ($r | ConvertTo-Json -Depth 5)
  42. } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }
  43. Write-Host ""
  44. # Try 6: REST fetch-style approach (Query endpoint)
  45. Write-Host "=== Try REST query with where ===" -ForegroundColor Cyan
  46. try {
  47. $body = @{
  48. _ApplicationId = $appId
  49. className = "APIG"
  50. where = @{ objectId = "Vo3ROWEvDy" }
  51. limit = 1
  52. } | ConvertTo-Json -Depth 3 -Compress
  53. $r = Invoke-RestMethod -Uri "https://server.fmode.cn/parse/functions/find" -Method POST -Headers $headers -Body $body -TimeoutSec 10
  54. Write-Host ($r | ConvertTo-Json -Depth 5)
  55. } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }