<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to make a basic XML API Request using C# in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-make-a-basic-xml-api-request-using-c/m-p/103611#M1258</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to learn how to use the API with a C# Client.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm able to make a API request, using a web browser, but can someone, give me an example in C#.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I wanted to use this example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make a call to get system information, which returns the IP address, hostname, and model of your firewall.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'https://&lt;/SPAN&gt;firewall&lt;SPAN&gt;//api/?type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;system&amp;gt;&amp;lt;info&amp;gt;&amp;lt;/info&amp;gt;&amp;lt;/system&amp;gt;&amp;lt;/show&amp;gt;&amp;amp;key=&lt;/SPAN&gt;apikey&lt;/P&gt;&lt;P&gt;response status="success"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;result&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;system&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;hostname&amp;gt;firewall&amp;lt;/hostname&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;ip-address&amp;gt;10.27.0.8&amp;lt;/ip-address&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to get this back into a form textbox, or a label.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will help me to learn how to use this API and Web Requests.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Troy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Aug 2016 20:49:05 GMT</pubDate>
    <dc:creator>Troy_Mitchell</dc:creator>
    <dc:date>2016-08-16T20:49:05Z</dc:date>
    <item>
      <title>How to make a basic XML API Request using C#</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-make-a-basic-xml-api-request-using-c/m-p/103611#M1258</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to learn how to use the API with a C# Client.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm able to make a API request, using a web browser, but can someone, give me an example in C#.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I wanted to use this example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make a call to get system information, which returns the IP address, hostname, and model of your firewall.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'https://&lt;/SPAN&gt;firewall&lt;SPAN&gt;//api/?type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;system&amp;gt;&amp;lt;info&amp;gt;&amp;lt;/info&amp;gt;&amp;lt;/system&amp;gt;&amp;lt;/show&amp;gt;&amp;amp;key=&lt;/SPAN&gt;apikey&lt;/P&gt;&lt;P&gt;response status="success"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;result&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;system&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;hostname&amp;gt;firewall&amp;lt;/hostname&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;ip-address&amp;gt;10.27.0.8&amp;lt;/ip-address&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to get this back into a form textbox, or a label.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will help me to learn how to use this API and Web Requests.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Troy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 20:49:05 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-make-a-basic-xml-api-request-using-c/m-p/103611#M1258</guid>
      <dc:creator>Troy_Mitchell</dc:creator>
      <dc:date>2016-08-16T20:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a basic XML API Request using C#</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-make-a-basic-xml-api-request-using-c/m-p/135364#M1332</link>
      <description>&lt;P&gt;This should get you started.&lt;/P&gt;&lt;P&gt;It's a console application that retrieve's the firewalls HostName, IP adress and model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Xml;

namespace PAN_API
{
    class Program
    {
        static string FirewallIP = "******";
        static string FirewallAPI = "******"; 
        static void Main(string[] args)
        {
            try
            {
                string requestURL = "https://" + FirewallIP + "/api/?type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;system&amp;gt;&amp;lt;info&amp;gt;&amp;lt;/info&amp;gt;&amp;lt;/system&amp;gt;&amp;lt;/show&amp;gt;&amp;amp;key=" + FirewallAPI;
                WebRequest request = WebRequest.Create(requestURL);
                request.Proxy = null;
                request.Credentials = CredentialCache.DefaultCredentials;
                ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                string responseFromServer = reader.ReadToEnd();
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(responseFromServer);
                Console.WriteLine("hostname: " + xmlDoc.GetElementsByTagName("hostname")[0].InnerText);
                Console.WriteLine("ip: " + xmlDoc.GetElementsByTagName("ip-address")[0].InnerText);
                Console.WriteLine("model: " + xmlDoc.GetElementsByTagName("model")[0].InnerText);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.Read();
            }
        }
        public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            return true;
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2017 13:57:18 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-make-a-basic-xml-api-request-using-c/m-p/135364#M1332</guid>
      <dc:creator>Sjoerd</dc:creator>
      <dc:date>2017-01-02T13:57:18Z</dc:date>
    </item>
  </channel>
</rss>

