Heiphaistos TutorialsHeiphaistosTutorials
🪟Windows🖥️CMD / PowerShell💬Discord🍎macOS🔐Sécurité🐧Linux🌐Réseau💻Programmation🤖Android📦Applications🔥Applications Heiphaistos📦Logiciels📦HeiApps

⚒ Heiphaistos Tutorials

Forge ton savoir informatique.
Tutoriels clairs, sans blabla.

Navigation

  • Accueil
  • Tous les tutoriels
  • Windows
  • Discord

Ressources

  • Flux RSS
  • heiphaistos.org

© 2026 Heiphaistos Tutorials — tuto.heiphaistos.org

Mentions légalesConfidentialitéCGU

Forge ton savoir.

Accueil/CMD / PowerShell/PowerShell : appeler une API web et télécharger (Invoke-RestMethod, Invoke-WebRequest)
🖥️CMD / PowerShellVidéo

PowerShell : appeler une API web et télécharger (Invoke-RestMethod, Invoke-WebRequest)

Interroger une API REST depuis PowerShell avec Invoke-RestMethod (GET, POST, en-têtes, JSON), télécharger un fichier avec Invoke-WebRequest, et envoyer une notification vers un webhook Discord.

9 octobre 20261 min de lecture
#powershell#api#invoke-restmethod#webhook
Votre navigateur ne supporte pas la lecture vidéo.
VitesseSous-titres : bouton CC du lecteur

Sommaire

  • Lire une API
  • Envoyer
  • Télécharger

Lire une API

$m = Invoke-RestMethod 'https://api.open-meteo.com/v1/forecast?latitude=45.76&longitude=4.84&current=temperature_2m'
$m.current.temperature_2m
Invoke-RestMethod https://api.github.com/repos/microsoft/terminal/releases/latest | Select-Object tag_name, published_at

Envoyer

$corps = @{ content = "Sauvegarde terminée" } | ConvertTo-Json
Invoke-RestMethod -Uri $env:DISCORD_WEBHOOK -Method Post -ContentType 'application/json; charset=utf-8' -Body ([Text.Encoding]::UTF8.GetBytes($corps))
Invoke-RestMethod $url -Headers @{ Authorization = "Bearer $env:API_JETON" }

Webhook Discord : créer un webhook.

Télécharger

Invoke-WebRequest 'https://exemple.fr/fichier.zip' -OutFile .\fichier.zip

Astuce PowerShell 5 : $ProgressPreference = 'SilentlyContinue' accélère beaucoup les téléchargements. Concepts : API REST.

Commentaires

Aucun commentaire pour l'instant. Soyez le premier !

Laisser un commentaire

En envoyant un commentaire, vous acceptez les conditions d'utilisation et la publication de votre pseudo après modération (voir la politique de confidentialité).