英文:
how to write equivalent of curl in powershell
问题
以下是翻译好的部分:
The following curl
command works in azure cli
.
以下curl
命令在azure cli
中有效。
I have created an equivalent on for powershell
on desktop but it fails. What am I doing wrong?
我在桌面上为powershell
创建了一个等效的命令,但它失败了。我做错了什么?
curl : {"error":{"code":"404","message": "Resource not found"}}
curl:{"error":{"code":"404","message":"未找到资源"}}
At line:1 char:1
在行:1字符:1
- curl https://aoai-try-mc.openai.azure.com/openai/deployments/try-davi ...
- curl https://aoai-try-mc.openai.azure.com/openai/deployments/try-davi...
-
- CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
CategoryInfo:InvalidOperation:(System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest],WebExc
eption
eption - FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
- FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
英文:
The following curl
command works in azure cli
.
curl https://aoai-try-mc.openai.azure.com/openai/deployments/try-davinci/completions?api-version=2022-12-01 -H "Content-Type:application/json" -H "api-key:keygoeshere" -d '{"prompt":"Tell me a funny story"}'
I have created an equivalent on for powershell
on desktop but it fails. What am I doing wrong?
PS C:\Users\manuchadha> curl https://aoai-try-mc.openai.azure.com/openai/deployments/try-davinci/completions?api-version=2022-12-01 -H @{"Content-Type"="application/json" ; "api-key"="keygoeshere"} -Body @{"prompt"="Tell me a funny story"}
curl : {"error":{"code":"404","message": "Resource not found"}}
At line:1 char:1
+ curl https://aoai-try-mc.openai.azure.com/openai/deployments/try-davi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
答案1
得分: 5
Powershell提供了一个别名用于“curl”,它实际上是运行invoke-webrequest
,这基本上永远不会为您执行正确的操作,而且大多数情况下只会破坏您尝试执行的任何操作。
绕过这种疯狂的简单方法是在命令行上键入curl.exe
而不仅仅是curl
。
Windows 10和11已经多年来捆绑了一个“真正的”curl工具。
英文:
Powershell provides an alias for "curl" that instead makes it run invoke-webrequest
which basically never does the right thing for you and will mostly just ruin whatever you try to do.
An easy way to circumvent this craziness is by typing out curl.exe
instead of just curl
on the command line.
Windows 10 and 11 have shipped a bundled "real" curl tool since several years by now.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论