Powershell to insert new records into Aristotle

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! :slight_smile:

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

UPDATE: I know the issue, it relates to the structure of the json body object not being quite right. So what I need to get right is build a distribution json object on the fly in Powershell.