使用cURL命令时出现URL问题 [英] URL issue while using cURL command

查看:68
本文介绍了使用cURL命令时出现URL问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用curl消耗Web服务时遇到了问题.如果我们使用Postman进行消费,则有一个URL可以正常工作,但通过cURL进行消费时,URL会失败.

I'm running into issue while using curl to consume a webservice. There is URL which works fine if we consume using Postman but fails when consumed via cURL.

Postman中的URL,效果很好:

URL in Postman, which works fine:

https://localhost/WebService/InvokeEventRule?EventRuleName=S3Copy&EventParams=

下面是cURL命令,该命令失败并给出错误消息,因为" EventParams无法识别为内部或外部命令"

Below is the cURL command, which fails and gives an error as 'EventParams is not recognized as an internal or external command'

curl -k -u testuser:Password0! --url https://localhost/WebService/InvokeEventRule?EventRuleName=S3Copy&EventParams=

在URL中的S3Copy之后通知与号(&),如果我将其替换为?,则cURL将不会出现上述错误,但我会收到错误请求",并且当然会替换&带有?的邮件也会在Postman中失败.

Notice the ampersand (&) after S3Copy in URL, if I replace it with ?, cURL will not give the error as mentioned above but the I'll get a 'Bad Request' and of course replacing & with ? will fail in Postman too.

有人可以建议为什么CURL不接受&符吗?还是失败了?

Could anybody advise why CURL is not accepting ampersand (&) but ? and anyway it's failing?

推荐答案

您需要用引号将网址包裹起来

You need to wrap the url with quotes

curl --request GET'https://api.github.com/repos/facebook/react/pulls?state=open&sort=updated'

注意:如果您使用的是邮递员,则可以通过单击邮递员中的 code 选项来获取卷曲请求示例.它将使用大多数编程语言生成您的代码.

NOTE: If you are using postman you can get the curl request sample by clicking on the code option in postman. It will generate your code in most of the programming language.

这篇关于使用cURL命令时出现URL问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆