I would like to automate a new NAT in NSX-T,
I'd like to automate the addition of a new nat from an API with Powershell.
Except that I still have a "400".
Here's an example of my Powershell script:
username =
$password =
$body = @{
"display_name = ""
"description" = ""
"action" = "DNAT
"destination_network" = ""
"translated_network" = ""
"translated_ports" = ""
"sequence_number" = 0
"enabled" = $true
"logging" = $false
"firewall_match" = ""
"scope" = @()
"_revision" = 0
} | ConvertTo-Json
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$headers = @{
"Authorization" = "Basic $base64AuthInfo"
Content-Type'='application/json'
}
try {
$results = Invoke-webrequest -uri "" -headers $headers -method patch -body $body
} catch {
Write-Host "Error : $($_.Exception.Message)"
Write-Host "HTTP error : $($_.Exception.Response.StatusCode.value__)"
Write-Host "Details : $($_.Exception.Response.StatusDescription)"
}