Download firewall activity error

Newb here. Other day I posted a request on how to download firewall activity. One of you very graciously pointed to the doc example on how to do this using curl. i followed the instructions, loaded in my api key etc and got it working. GREAT. i saved the query in a text doc knowing I would want to rerun it. I copy it and paste into a my osx terminal window and receive the following error:

under sh shell i get this error:
{“data”:null,“errors”:[{“message”:“failed to recognize JSON request: ‘invalid character ‘\n’ in string literal’”,“path”:null,“extensions”:{“timestamp”:“2022-03-07T18:41:55.949928313Z”}}]}

under bash command i get this error:
{“data”:null,“errors”:[{“message”:“failed to recognize JSON request: ‘invalid character ‘f’ after object key:value pair’”,“path”:null,“extensions”:{“timestamp”:“2022-03-07T19:33:48.647478485Z”}}]}

Here is my curl command with sensitive variable blanked out:

PAYLOAD=’{ “query”:
“query ListFirewallEvents($zoneTag: string, $filter: FirewallEventsAdaptiveFilter_InputObject) {
viewer {
zones(filter: { zoneTag: $zoneTag }) {
filter: $filter
limit: 10000
orderBy: [datetime_DESC]
) {
“variables”: {
“zoneTag”: “my-zone-id”,
“filter”: {
“datetime_geq”: “2022-02-25T00:00:00Z”,
“datetime_leq”: “2022-02-25T02:00:00Z”

“$(echo $PAYLOAD)”

curl -X POST -H “Content-Type: application/json” -H “X-Auth-Email: [email protected]” -H “X-Auth-key: my-key” --data “$(echo $PAYLOAD)”

Any ideas on what I am doing wrong, like i said - it ran perfectly last week?

I don’t think your query is escaping all of the special JSON characters correctly. I would try reformatting your example as per the developer docs example for cURL:


Thank you so much for your suggestion which is based on a bash script. here’s what i did:

to use the script i did the following - btw, my os is osx monterey 12.1:

i changed the script to use: #!/bin/bash
I replaced the $1 and $2 params with the correct values - enclosed in strings
i made the script executable: “chmod u+x”
i ran the script: sh ./

nothing happened - after running the script i was immediately returned to the terminal prompt with no output. i tried directing output to a file and re-running. when i did the output file had 0 bytes. what am i doing wrong?

UPDATE: i copied the script from my goto editor BBEdit to osx’s native TextEdit and it worked fine. Thank you - any suggestions what is going on with my editors - does it have to do with cr/lf?

Yes - I assume your editor is not encoding the control characters correctly in that case. I’m not familiar with BBEdit so you’d need to check with their documentation - it may be the file has been saved in a different OS format.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.