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

FortiAnalyzer API

Hi, I am trying to use the FortiAnalyzer web service with C# to get statistics out of the Analyzer for reporting purposes. At this stage I have added a service reference in Visual Studio to the FortiAnalyzer URL and have access to the classes provided by the WSDL file. The bit im not sure on is how to actually send requests to the analyzer through code - I have searched for documentation about the API and only managed to find the version 4 MR3 technical document located here Can someone provide some sample C# coding they have used to get statistics out of the fortianalyzer or perhaps point me in the direction of some documentation which covers how to send and retrieve request would be greatly appreciated!
6 REPLIES 6
dubbsix
New Contributor

Isnt the data stored in a SQL database? Cant you build a query in C# to pull back the data you need? what type of stats are you looking to get back from the analyzer?
Fortinet FanBoy.
Fortinet FanBoy.
Nav
New Contributor

Hi, Yes, the data is stored in an SQL database - however isn' t the database built into the Analyzer? I have not found documentation as yet on how to connect to the SQL database directly and query for information. I am looking to get web filtering data and possibly other UTM data from the analyzer for each firewall thats configured on it. Thanks for your reply!
brhunt
New Contributor

I' m in the same boat. Without some program examples (C# or VB), impossible to proceed. I have a case open with TAC on getting some examples, but no joy yet. Thanks. Bryan Hunt
brhunt
New Contributor

All, Okay, I was able to *finally* work my way through to a working example. Download the WSDL and set up a web reference to it.
using System.Net;
 using System.Net.Security;
 using System.Security.Cryptography.X509Certificates;
 using FortianalyzerAPI.FA;
 
 namespace FortianalyzerAPI
 {
     class Program
     {
         static void Main(string[] args)
         {
             //
             // Need this to stop exception from being thrown on invalied SSL certificate on FA unit.
             //
             ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain,
                 SslPolicyErrors sslPolicyErrors) { return true; };
 
             // Create web service
             FortiAnalyzerWS ws = new FortiAnalyzerWS();
 
             // Point webservice to FA webservice entry point
             ws.Url = @" https://172.16.99.205:8080/FortiAnalyzerWS" ;
 
             // Create message request, message request header, message request body
             FortiRequest mr = new FortiRequest();
             RequestHeader mrh = new RequestHeader();
             RequestBody mrb = new RequestBody();
 
             // Link the header and the body to the request
             mr.Header = mrh;
             mr.Body = mrb;
 
             // Credentials into the header
             mrh.UserName = " admin" ;
             mrh.Password = " password" ;
 
             // Load the request type
             mrb.Item = new FortiAnalyzerGetSystemStatus();
 
             // Make the request            
             FortiResponse myResponse = ws.FortiRequest(mr);
         }
     }
 }
Nav
New Contributor

Awesome! Seems that they have changed the way this works on version 5 though - so if you update your Analyzer to FortiOS5 these methods no longer work... I will continue to work on this and see if i can figure it out
Nav
New Contributor

still no luck with version 5 - not sure if anyone else has made any progress?
Labels
Top Kudoed Authors