将dataurlencoded curl命令转换为powershell交点{error quord; quot'invalid_request" error_description" quot; quot; quot;
我需要将数据 - 纯编码卷曲命令转换为powershell的帮助 任何帮助都将不胜感激
curl --location --request POST https://anypoint.muloft.com/accounts/api/v2/oauth2/token --header 'Content-Type:application/x-www-form-urlencoded' --data-urlencode 'client_id=44b1d81330084afbb39c74' --data-urlencode 'client_secret=c38042cda4FD6af9fc18' --data-urlencode 'grant_type=client_credentials'
,我尝试了
$contentType = 'application/x-www-form-urlencoded'
PS C:\Users\mation> Invoke-WebRequest -Uri ("https://anypoint.muloft.com/accounts/api/v2/oauth2/token") -ContentType $contentType -Method Post -Body { client_id="44b1d81330039c74" ;client_secret = "c38042cE3D6af9fc18" ; grant_type= "authorization_code" }
Invoke-WebRequest : {"error":"invalid_request","error_description":"Invalid grant_type"}
At line:1 char:1
+ Invoke-WebRequest -Uri ("https://anypoint.mulesoft.com/accounts/api/v ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I need help with converting data-urlencoded curl command to powershell
Any help would be highly appreciated
curl --location --request POST https://anypoint.muloft.com/accounts/api/v2/oauth2/token --header 'Content-Type:application/x-www-form-urlencoded' --data-urlencode 'client_id=44b1d81330084afbb39c74' --data-urlencode 'client_secret=c38042cda4FD6af9fc18' --data-urlencode 'grant_type=client_credentials'
I tried this but i am getting
$contentType = 'application/x-www-form-urlencoded'
PS C:\Users\mation> Invoke-WebRequest -Uri ("https://anypoint.muloft.com/accounts/api/v2/oauth2/token") -ContentType $contentType -Method Post -Body { client_id="44b1d81330039c74" ;client_secret = "c38042cE3D6af9fc18" ; grant_type= "authorization_code" }
Invoke-WebRequest : {"error":"invalid_request","error_description":"Invalid grant_type"}
At line:1 char:1
+ Invoke-WebRequest -Uri ("https://anypoint.mulesoft.com/accounts/api/v ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是对我有用的
$ requestAccestokenuri =“ https://anypoint.muloft.com/accounts/api/v2/oauth2/oauth2/token”
$ clientId =“ 44b1d8bb39c74
”
$ clientsecret =“ client_id = $ clientId& client_secret = $ clientsecret'
$ token = invoke -reastmethod -method post -uri $ requestAccestokestokenuri -body $ body $ contentType'申请/x -www -form -urlenced'''''
Below is what worked for me
$RequestAccessTokenUri = "https://anypoint.muloft.com/accounts/api/v2/oauth2/token"
$ClientId = "44b1d8bb39c74"
$ClientSecret = "c380f9fc18"
$body = "grant_type=client_credentials&client_id=$ClientId&client_secret=$ClientSecret"
$Token = Invoke-RestMethod -Method Post -Uri $RequestAccessTokenUri -Body $body -ContentType 'application/x-www-form-urlencoded'