<?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: how to resolve 'Unexpected DTD declaration' error when logging on using the C# sdk? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/how-to-resolve-Unexpected-DTD-declaration-error-when-logging-on/m-p/491113#M8837</link>
    <description>&lt;P&gt;the exception in my Splunk Answers post is thrown by this line code:&lt;BR /&gt;
await service.Configurations.GetAllAsync();&lt;BR /&gt;
The program has been quit before running LogOnAsync(username, password).&lt;/P&gt;</description>
    <pubDate>Thu, 17 Oct 2019 03:04:13 GMT</pubDate>
    <dc:creator>xy12345</dc:creator>
    <dc:date>2019-10-17T03:04:13Z</dc:date>
    <item>
      <title>how to resolve 'Unexpected DTD declaration' error when logging on using the C# sdk?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/how-to-resolve-Unexpected-DTD-declaration-error-when-logging-on/m-p/491111#M8835</link>
      <description>&lt;P&gt;I copied the C# Logon code from example and tried to logon to my Splunk service (&lt;A href="http://10.134.21.107:8000" target="_blank"&gt;http://10.134.21.107:8000&lt;/A&gt;). When running the C# code, I got the 'Unexpected DTD declaration' error. This error is the same with "&lt;A href="https://answers.splunk.com/answers/518826/why-am-i-receiving-an-xmlexception-when-logging-on.html" target="_blank"&gt;https://answers.splunk.com/answers/518826/why-am-i-receiving-an-xmlexception-when-logging-on.html&lt;/A&gt;". Different from it is that I can make sure that my URL endpoint is correct since it (&lt;A href="http://10.134.21.107:8000" target="_blank"&gt;http://10.134.21.107:8000&lt;/A&gt;) can be accessed by the browser.&lt;BR /&gt;My code is below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Splunk.Client;
namespace mytest
{
    class Program
    {
        static void Main(string[] args)
        {
            string host = "10.134.21.107";
            int port = 8000;
            Scheme scheme = Scheme.Http;

            using (var service = new Service(scheme, host, port))
            {
                Console.WriteLine("Connected to {0}:{1} ", service.Context.Host, service.Context.Port);
                try
                {
                    Run(service).Wait();
                }
                catch (AggregateException ex)
                {
                    ex.Handle(exception =&amp;gt;
                    {

                        Console.WriteLine(exception.Message);
                        Console.WriteLine(exception.Source);
                        Console.WriteLine(exception.ToString());
                        Console.WriteLine(exception.StackTrace);
                        Console.WriteLine(exception.TargetSite.ToString());
                        return true;
                    });

                }
            }

            Console.Write("Press return to exit: ");
            Console.ReadLine();
        }


        private static async Task Run(Service service)
        {
            string username = "tester";
            string password = "Xxxx1122";
            try
            {
                await service.Configurations.GetAllAsync();
            }
            catch (AuthenticationFailureException)
            {
                Console.WriteLine("Can't get service configuration without logging in.");
            }

            await service.LogOnAsync(username, password);

            Console.WriteLine("List all configurations of the Splunk service:");
            await service.Configurations.GetAllAsync();

            foreach (Configuration config in service.Configurations)
            {
                Console.WriteLine(config.Id);
            }

            Console.WriteLine("Log off");
            await service.LogOffAsync();
        }


    }
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output is below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Connected to 10.134.21.107:8000
Unexpected DTD declaration. Line 1, position 3.
System.Xml
System.Xml.XmlException: Unexpected DTD declaration. Line 1, position 3.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContentAsync()
   at System.Xml.XmlTextReaderImpl.ReadAsync()
   at System.Xml.XmlTextReaderImpl.ReadAsync_SwitchToInteractiveXmlDecl_Helper(Boolean finish)
   at System.Xml.XmlTextReaderImpl.ReadAsync_SwitchToInteractiveXmlDecl()
   at System.Xml.XmlTextReaderImpl.ReadAsync()
   at System.Xml.AsyncHelper.&amp;lt;_CallBoolTaskFuncWhenFinish&amp;gt;d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.XmlReaderExtensions.&amp;lt;MoveToDocumentElementAsync&amp;gt;d__2.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\XmlReaderExtensions.cs:line 182
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.Message.&amp;lt;ReadMessagesAsync&amp;gt;d__21.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\Message.cs:line 428
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.Response.&amp;lt;ThrowRequestExceptionAsync&amp;gt;d__17.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\Response.cs:line 214
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.Response.&amp;lt;EnsureStatusCodeAsync&amp;gt;d__11.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\Response.cs:line 157
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.EntityCollection`2.&amp;lt;GetAllAsync&amp;gt;d__12.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\EntityCollection.cs:line 243
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at mytest.Program.&amp;lt;Run&amp;gt;d__1.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\mytest\Program.cs:line 51
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContentAsync()
   at System.Xml.XmlTextReaderImpl.ReadAsync()
   at System.Xml.XmlTextReaderImpl.ReadAsync_SwitchToInteractiveXmlDecl_Helper(Boolean finish)
   at System.Xml.XmlTextReaderImpl.ReadAsync_SwitchToInteractiveXmlDecl()
   at System.Xml.XmlTextReaderImpl.ReadAsync()
   at System.Xml.AsyncHelper.&amp;lt;_CallBoolTaskFuncWhenFinish&amp;gt;d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.XmlReaderExtensions.&amp;lt;MoveToDocumentElementAsync&amp;gt;d__2.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\XmlReaderExtensions.cs:line 182
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.Message.&amp;lt;ReadMessagesAsync&amp;gt;d__21.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\Message.cs:line 428
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.Response.&amp;lt;ThrowRequestExceptionAsync&amp;gt;d__17.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\Response.cs:line 214
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.Response.&amp;lt;EnsureStatusCodeAsync&amp;gt;d__11.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\Response.cs:line 157
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Splunk.Client.EntityCollection`2.&amp;lt;GetAllAsync&amp;gt;d__12.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\src\Splunk.Client\Splunk\Client\EntityCollection.cs:line 243
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at mytest.Program.&amp;lt;Run&amp;gt;d__1.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\mytest\Program.cs:line 51
Void Throw(System.Exception)
Press return to exit:
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks for any help.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2020 18:50:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/how-to-resolve-Unexpected-DTD-declaration-error-when-logging-on/m-p/491111#M8835</guid>
      <dc:creator>xy12345</dc:creator>
      <dc:date>2020-06-07T18:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to resolve 'Unexpected DTD declaration' error when logging on using the C# sdk?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/how-to-resolve-Unexpected-DTD-declaration-error-when-logging-on/m-p/491112#M8836</link>
      <description>&lt;P&gt;Could you please try using the Splunk management port (default: &lt;STRONG&gt;8089&lt;/STRONG&gt;) as in the example &lt;A href="https://dev.splunk.com/view/csharp-sdk-pcl/SP-CAAAEYF"&gt;here&lt;/A&gt;?  All the REST API endpoints are exposed over that port and not the default Splunk UI Web port (8000).&lt;/P&gt;

&lt;P&gt;For example: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;// Create a Service instance 
var service = new Service(Scheme.Https, "localhost", 8089, new Namespace(user: "nobody", app: "search"))

// Log in
await service.LoginAsync("admin", "yourpassword");
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 13:15:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/how-to-resolve-Unexpected-DTD-declaration-error-when-logging-on/m-p/491112#M8836</guid>
      <dc:creator>ccl0utier</dc:creator>
      <dc:date>2019-10-16T13:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to resolve 'Unexpected DTD declaration' error when logging on using the C# sdk?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/how-to-resolve-Unexpected-DTD-declaration-error-when-logging-on/m-p/491113#M8837</link>
      <description>&lt;P&gt;the exception in my Splunk Answers post is thrown by this line code:&lt;BR /&gt;
await service.Configurations.GetAllAsync();&lt;BR /&gt;
The program has been quit before running LogOnAsync(username, password).&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 03:04:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/how-to-resolve-Unexpected-DTD-declaration-error-when-logging-on/m-p/491113#M8837</guid>
      <dc:creator>xy12345</dc:creator>
      <dc:date>2019-10-17T03:04:13Z</dc:date>
    </item>
  </channel>
</rss>

