将dataurlencoded curl命令转换为powershell交点{error quord; quot'invalid_request" error_description" quot; quot; quot;

发布于 2025-02-08 01:06:14 字数 1229 浏览 3 评论 0原文

我需要将数据 - 纯编码卷曲命令转换为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生寂 2025-02-15 01:06:14

以下是对我有用的

$ 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'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文