'How can I connect to my REST API with powershell (CYPHERTRUST)

I am searching for how to connect to my rest API with a Powershell script

I know that I need a to send my Body with the POST Method but cant define how to do it

There is documentation where they talk about tokens:

Its what I need to call with Invoke Rest-Method

https://10.75.8.128/playground_v2/api/Tokens#/v1/auth/tokens/-post

And there is that body that I need to send :

{
  "grant_type": "password",
  "username": "steve",
  "password": "mysecretword",
  "labels": [
    "myapp",
    "cli"
  ]
}

I tried this but it doesn't work

$person = @{
  "grant_type": "password",
  "username": "username",
  "password": "MDP",
  "labels": [
    "myapp",
    "cli"
  ]
}

Invoke-RestMethod

$person "https://10.75.8.128/playground_v2/api/v1/auth/tokens" -Method Post 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source