Anyone used Powershell to make a post request?
I’m very new to Powershell and am just starting to figure it out for a new project. Now I’ve gotten a GET call working to /metadata/distribution, but have had no luck yet with POST to upload a new distribution.
Trying either Invoke-WebRequest or Invoke-RestMethod. Either approach yields the same error, “{“name”:[“This field is required.”]}”, though the only place I know name is required is in the payload json for the new distribution, which I have supplied…
I had thought my distribution json was fine, as I had it working via Python. If anyone has a working restful PUT call, I’d appreciate a peek thanks!
Essentially here’s what I’m trying:
–Get the new distribution from a local file
$jsonData = Get-Content “distribution_template.json” | Out-String | ConvertFrom-Json$putDistURL = “https://aristotle_url_here/api/v4/metadata/distribution”
–Headers defined to authenticate
$headers = @{ Accept = ‘application/json’
Authorization = ‘Token blahblahblah’
}$dataResponse = Invoke-RestMethod -Uri $putDistURL -Method Post -Headers $headers -Body $jsonData