JSON ile Invoke-RestMethod PowerShell Nasıl Kullanılır?

Şöyle bir json scriptim bura da kalsın zamanla bunu daha iyi sadeleştireceğim

$Api="http://localhost:4880/api/Operation"
$EndPoint="/AddUser"
$Url= "$Api$EndPoint"


$KullaniciAd = Read-Host "User Name"
$AdSoyad = Read-Host "Name"
$Email = Read-Host "E-Mail"
$Sifre = Read-Host "Şifre"
$Referans = Read-Host "Referance"

$bodyCred =   @"
{
    "UNAME": "$KullaniciAd",
    "PASS" : "$Sifre", 
    "SNAME": "$AdSoyad",
    "EMAIL": "$Email",
    "REF"  : "$Referans"
}

"@
$utf8Bytes = [System.Text.Encoding]::UTf8.GetBytes($bodyCred)
$bodyCred = $defaultEncoding.GetString($utf8Bytes)
$response = Invoke-WebRequest $Url -UseDefaultCredentials -SessionVariable my_session -UseBasicParsing -Method Post -Headers $headers -Body $bodyCred -ContentType 'application/json' | ConvertFrom-Json
      

Leave a Reply