Skip to main content
Nav
New Member
November 6, 2012
Question

FortiAnalyzer API

  • November 6, 2012
  • 6 replies
  • 7339 views
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

    dubbsix
    New Member
    November 20, 2012
    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?
    Nav
    NavAuthor
    New Member
    November 20, 2012
    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 Member
    November 28, 2012
    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 Member
    December 6, 2012
    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
    NavAuthor
    New Member
    December 7, 2012
    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
    NavAuthor
    New Member
    June 24, 2013
    still no luck with version 5 - not sure if anyone else has made any progress?
    Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
    Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!