Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
noamsh88
New Contributor II

How to download system events logs using bash curl?

i'm trying to download system events logs using bash curl and getting authentication error

curl -u 'fortigate_user:fortigate_pass'  'https://<fortigate ip address>/api/v2/log/memory/event/system/raw' --compressed --insecure

 

and getting following authentication error:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<p>Additionally, a 401 Unauthorized
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

 

how can we passthrough the API login for curl command (-u 'fortigate_user:fortigate_pass' ) in order to download the log? 


note: if i login to FortiGate via chrome and on other tab to  'https://<fortigate ip address>/api/v2/log/memory/event/system/raw' i'm able to download the log (session token) , but we aim to download it from bash command line

1 Solution
bpozdena_FTNT

Hi @noamsh88 ,

the easiest way is to authenticate by using API Key. But you can also login with your credentials and then use the session cookie.

 

Both methods are described at https://community.fortinet.com/t5/FortiGate/Technical-Tip-About-REST-API/ta-p/195425

 

HTH,
Boris

View solution in original post

1 REPLY 1
bpozdena_FTNT

Hi @noamsh88 ,

the easiest way is to authenticate by using API Key. But you can also login with your credentials and then use the session cookie.

 

Both methods are described at https://community.fortinet.com/t5/FortiGate/Technical-Tip-About-REST-API/ta-p/195425

 

HTH,
Boris
Labels
Top Kudoed Authors