我有一个用例,用于从存储设备中获取最后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"
以上卷曲仅触发至以下:
"https://mystorageipaddress.com/api/types/event/instances?per_page=2000&compact=true"
请建议
您必须将具有特殊含义的字符转义到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"
当然,如果您愿意,也可以在字符串周围使用单引号进行转义,而不是使用反斜杠。