test_post.ps1 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Script PowerShell pour tester la requête POST_userV2.php
  2. # avec toutes les données récupérées depuis les endpoints
  3. $jsonFile = Join-Path $PSScriptRoot "post_user_request.json"
  4. $url = "http://localhost/api/user/user/POST_userV2.php"
  5. if (-not (Test-Path $jsonFile)) {
  6. Write-Host "❌ Erreur: Le fichier $jsonFile n'existe pas!" -ForegroundColor Red
  7. exit 1
  8. }
  9. Write-Host "📋 Fichier JSON: $jsonFile" -ForegroundColor Cyan
  10. Write-Host "🌐 URL: $url" -ForegroundColor Cyan
  11. Write-Host ""
  12. Write-Host "🚀 Envoi de la requête POST..." -ForegroundColor Yellow
  13. Write-Host ""
  14. try {
  15. $jsonContent = Get-Content $jsonFile -Raw
  16. $response = Invoke-RestMethod -Uri $url -Method Post -Body $jsonContent -ContentType "application/json" -ErrorAction Stop
  17. Write-Host "✅ Succès!" -ForegroundColor Green
  18. Write-Host ""
  19. Write-Host "📄 Réponse:" -ForegroundColor Cyan
  20. $response | ConvertTo-Json -Depth 10
  21. } catch {
  22. Write-Host "❌ Erreur lors de la requête:" -ForegroundColor Red
  23. Write-Host $_.Exception.Message -ForegroundColor Red
  24. if ($_.ErrorDetails) {
  25. Write-Host $_.ErrorDetails.Message -ForegroundColor Red
  26. }
  27. }