Quantcast
Channel: Questions in topic: "splunk-enterprise"
Viewing all articles
Browse latest Browse all 47296

how to resolve 'Unexpected DTD declaration' error when logging on using the C# sdk?

$
0
0
I copied the C# Logon code from example and tried to logon to my Splunk service (http://10.134.21.107:8000). When running the C# code, I got the 'Unexpected DTD declaration' error. This error is the same with "https://answers.splunk.com/answers/518826/why-am-i-receiving-an-xmlexception-when-logging-on.html". Different from it is that I can make sure that my URL endpoint is correct since it (http://10.134.21.107:8000) can be accessed by the browser. My code is below: 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 => { 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(); } } } The output is below: 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.<_CallBoolTaskFuncWhenFinish>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.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.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.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.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.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.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.<_CallBoolTaskFuncWhenFinish>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.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.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.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.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.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.d__1.MoveNext() in E:\tt\ConsoleApplication3\splunk_ex\example\mytest\Program.cs:line 51 Void Throw(System.Exception) Press return to exit: Thanks for any help.

Viewing all articles
Browse latest Browse all 47296

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>