<?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 Re: Accessing via C# RESTful in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/97999#M20445</link>
    <description>&lt;P&gt;Your Base URL is wrong.&lt;/P&gt;

&lt;P&gt;Try :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;private static string BaseUrl = "https://localhost:8089";
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;FYI : Java, Python and Javascript SDK's &lt;A href="http://dev.splunk.com/view/sdks/SP-CAAADP7"&gt;available here&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Mar 2012 09:44:54 GMT</pubDate>
    <dc:creator>Damien_Dallimor</dc:creator>
    <dc:date>2012-03-21T09:44:54Z</dc:date>
    <item>
      <title>Accessing via C# RESTful</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/97998#M20444</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
I have been looking around to build an application to using C# RESTful services to gain access to splunk. So far I have not been able to get even the session. Below is the code that I have implemented&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;private static string BaseUrl = "http://localhost:8000";
        static void Main(string[] args)
        {
            var client = new WebClient();
            var parameters = new Dictionary&amp;lt;string, string&amp;gt;         
                { 
                    { "username", "admin" },
                    { "password", "mypassword" }
                };

            var result = client.UploadString(String.Format("{0}/services/auth/login", BaseUrl),UrlEncode(parameters));
            var doc = XDocument.Load(result);  // load response into XML document (LINQ)
            var key = doc.Elements("sessionKey").Single().Value; // get the one-and-only &amp;lt;sessionKey&amp;gt; element.
            Console.WriteLine("====&amp;gt;sessionkey:  {0}  &amp;lt;====", key);
        }

        // Utility function: 
        private static string UrlEncode(IDictionary&amp;lt;string, string&amp;gt; parameters)
        {
            var sb = new StringBuilder();
            foreach (var val in parameters)
            {
                // add each parameter to the query string, url-encoding the value.
                sb.AppendFormat("{0}={1}&amp;amp;", val.Key, HttpUtility.UrlEncode(val.Value));
            }
            sb.Remove(sb.Length - 1, 1); // remove last '&amp;amp;'
            return sb.ToString();
        }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I keep getting the &lt;CODE&gt;"404"&lt;/CODE&gt; error continuously on client.UploadString() method. Am I missing something? Do I need to startup some service related to Splunk before I can execute the code above? Splunkd and SplunkWeb are already running as a service. Win7 X64.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 09:24:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/97998#M20444</guid>
      <dc:creator>wajihullahbaig</dc:creator>
      <dc:date>2012-03-21T09:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing via C# RESTful</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/97999#M20445</link>
      <description>&lt;P&gt;Your Base URL is wrong.&lt;/P&gt;

&lt;P&gt;Try :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;private static string BaseUrl = "https://localhost:8089";
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;FYI : Java, Python and Javascript SDK's &lt;A href="http://dev.splunk.com/view/sdks/SP-CAAADP7"&gt;available here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 09:44:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/97999#M20445</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-03-21T09:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing via C# RESTful</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/98000#M20446</link>
      <description>&lt;P&gt;@Damien- Thanks for the answer. I know the other SDK's. But I have to use C#. Trying out your suggestion for the fix.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 10:08:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/98000#M20446</guid>
      <dc:creator>wajihullahbaig</dc:creator>
      <dc:date>2012-03-21T10:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing via C# RESTful</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/98001#M20447</link>
      <description>&lt;P&gt;OK. Seems to I now have a weak eye sight! But thanks. Working.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 10:18:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/98001#M20447</guid>
      <dc:creator>wajihullahbaig</dc:creator>
      <dc:date>2012-03-21T10:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing via C# RESTful</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/98002#M20448</link>
      <description>&lt;P&gt;Hope you can try with this below URL:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/5909/push-splunk-events-from-net-application"&gt;http://splunk-base.splunk.com/answers/5909/push-splunk-events-from-net-application&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thnx.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2012 05:47:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/98002#M20448</guid>
      <dc:creator>chhavi</dc:creator>
      <dc:date>2012-09-24T05:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing via C# RESTful</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/98003#M20449</link>
      <description>&lt;P&gt;C# SDK is available now! &lt;A href="https://github.com/splunk/splunk-sdk-csharp"&gt;https://github.com/splunk/splunk-sdk-csharp&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2013 22:44:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Accessing-via-C-RESTful/m-p/98003#M20449</guid>
      <dc:creator>wcolgate_splunk</dc:creator>
      <dc:date>2013-03-28T22:44:23Z</dc:date>
    </item>
  </channel>
</rss>

