首页 > 解决方案 > curl - 带有反斜杠的参数不通过

问题描述

在 Windows 环境中工作

我可以用 wget 执行这个命令,它可以工作:

wget --method GET "http://localhost/command?folderSource=\\myshare\myfolder&folderDestination=\\myshare\myfolder"

但是下面的 curl 命令在服务器上给出了一个错误:java.lang.IllegalArgumentException: Invalid character found in the request target。有效字符在 RFC 7230 和 RFC 3986 中定义

curl --request GET "http://localhost:8090/command?folderSource=\\myshare\myfolder&folderDestination=\\myshare\myfolder"

我已将其范围缩小到具有反斜杠的参数......没有反斜杠,服务器可以很好地接收两个参数。我试过用额外的反斜杠转义反斜杠......我试过添加一个,两个和三个,,,,没有运气。我也尝试过对参数值进行 URL 编码,但没有成功。非常感谢有关如何在 Windows 上通过 curl 传递包含反斜杠的参数的帮助

标签: curl

解决方案


谢谢,这让我发现使用参数 --data-urlencode,它有效!


推荐阅读