Tester l'API (PowerShell)

Lien isolé Accueil docs Formation
Mobile POS

Commandes PowerShell et curl pour tester login et API mobile.

Tester l'API depuis PowerShell (Windows)

Sous Windows, curl dans PowerShell est un alias de Invoke-WebRequest, qui n'utilise pas la même syntaxe que curl. Utilise l'une des méthodes suivantes.

Méthode 1 : Invoke-WebRequest (PowerShell)

Invoke-WebRequest -Uri "http://localhost:8001/api/mobile/auth/login" -Method POST -ContentType "application/json" -Body '{"shop_code":"B0001","email":"ton_email","password":"ton_mot_de_passe"}'

Pour voir la réponse en clair :

(Invoke-WebRequest -Uri "http://localhost:8001/api/mobile/auth/login" -Method POST -ContentType "application/json" -Body '{"shop_code":"B0001","email":"ton_email","password":"ton_mot_de_passe"}').Content

Méthode 2 : curl.exe (vrai curl Windows)

Si curl est installé, appelle-le explicitement :

curl.exe -X POST http://localhost:8001/api/mobile/auth/login -H "Content-Type: application/json" -d "{\"shop_code\":\"B0001\",\"email\":\"ton_email\",\"password\":\"ton_mot_de_passe\"}"

Méthode 3 : Postman

  1. Télécharge Postman (postman.com).
  2. POST → http://localhost:8001/api/mobile/auth/login
  3. Body → raw → JSON → colle le JSON avec shop_code, email, password.

Remplace ton_email et ton_mot_de_passe par les identifiants d'un utilisateur de ta base (avec accès à la boutique B0001).

Smoke test manager (auto env + pre-check réseau)

Le script scripts/mobile-manager-smoke.ps1 teste :

  • GET /api/mobile/manager/roles
  • POST /api/mobile/manager/users
  • POST /api/mobile/manager/customers

Il lit automatiquement Token, ShopId et BaseUrl depuis les arguments, puis les variables d'environnement, puis .env.

Variables reconnues :

  • Token: MOBILE_API_TOKEN, API_TOKEN, TOKEN
  • Shop: SHOP_ID, MOBILE_SHOP_ID
  • Base URL: MOBILE_API_BASE_URL, BASE_URL, API_BASE_URL, APP_URL

Exécution automatique :

.\scripts\mobile-manager-smoke.ps1

Exécution manuelle :

.\scripts\mobile-manager-smoke.ps1 -Token "TON_TOKEN" -ShopId 1 -BaseUrl "http://localhost:8001"

Le script fait d'abord un pré-check de connectivité API. Si le serveur est inaccessible, il s'arrête avec un message clair avant de lancer les appels manager.