如何查询CURL

5tmbdcev  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(155)

我有一个用例,从存储设备中获取最后5分钟的数据。当我在python中添加时,API运行良好,但在添加到curl中时,它并没有传递整个内容。

curl -X GET -H "X-EMC-REST-CLIENT: true" -H "Accept: application/json" -H "Content-type: application/json" -b cookies1.txt -L -k -u admin:xxxxxxx https://mystorageipaddress.com/api/types/event/instances?compact=true&fields=id,node,creationTime,severity,messageId,arguments,message,category,source,username&filter=creationTime GT "2022-11-02T10:35:09.927Z"

以上 curl 仅在以下情况下触发:

"https://mystorageipaddress.com/api/types/event/instances?per_page=2000&compact=true"

请建议

qgelzfjb

qgelzfjb1#

您必须将具有特殊含义的字符转义到shell中,即

https://mystorageipaddress.com/api/types/event/instances\?compact=true\&fields=id,node,creationTime,severity,messageId,arguments,message,category,source,username\&filter=creationTime\ GT\ \"2022-11-02T10:35:09.927Z\"

然而,我怀疑GT前后的空格是否真的应该出现在URL中,你必须用%20来表示它们,比如

https://mystorageipaddress.com/api/types/event/instances\?compact=true\&fields=id,node,creationTime,severity,messageId,arguments,message,category,source,username\&filter=creationTime%20GT%20\"2022-11-02T10:35:09.927Z\"

当然,如果您愿意,也可以在字符串两边使用单引号代替反斜杠进行转义。

相关问题