Home > Net >  How to query on CURL
How to query on CURL

Time:11-02

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

CodePudding user response:

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 , 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 GT \"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.

  • Related