如何与PowerShell(cyphertrust)连接到我的REST API
我正在寻找如何使用PowerShell脚本连接到我的REST API
,我知道我需要使用Post方法发送我的身体,但不能定义如何做到这一点,
有文档他们在谈论代币:
这是我需要的。 方法打电话
https://10.75.8.128/playground_v2/api/Tokens#/v1/auth/tokens/-post
,我需要发送那个机构:
{
"grant_type": "password",
"username": "steve",
"password": "mysecretword",
"labels": [
"myapp",
"cli"
]
}
我尝试过,但它不起作用
$person = @{
"grant_type": "password",
"username": "username",
"password": "MDP",
"labels": [
"myapp",
"cli"
]
}
用Invoke rest
$person "https://10.75.8.128/playground_v2/api/v1/auth/tokens" -Method Post
I am searching for how to connect to my rest API with a Powershell script
I know that I need to send my Body with the POST Method but can't 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面的代码对我来说很好:
从CipherTrust Manager收到的JSON响应中获得了JWT令牌。
希望这会有所帮助。
旁注:我不确定是否需要...我确实创建了一个示例PowerShell脚本来在CipherTrust Manager上执行一些复杂的API操作,否则该脚本将需要相当多的基于UI的步骤。 github链接
Below code worked for me just fine:
Got the jwt token back from the JSON response received from Ciphertrust Manager.
Hope this helps.
side note: I am not sure if it is required... I did create a sample powershell script to perform a few complex API operations on ciphertrust manager that would otherwise require quite a few UI based steps. GitHub Link Here