shellcurlcurl-commandline

How to query on CURL


I have a use case, to fetch the last 5 minute data from the storage device. The API runs fine when i added in python, but while adding into curl, it is not passing the whole content.

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"

Above curl is only triggering till below :

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

Please suggest


Solution

  • You have to escape the characters with special meaning to the shell, i.e.

    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\" 
    

    However, I doubt that the spaces before and after GT should really be in the URL. You would have to represent them by %20, i.e. something like

    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\" 
    

    Of course you can also use single quotes around the string for escaping instead of a backslash, if you prefer.