Dashboards & Visualizations

C# SDK: Why am I getting XML Error "'doctype' is an unexpected token. The expected token is '

urbanwks
Engager

I am implementing the C# SDK, and I am running into an error with the LogOnAsync function. My (copied from example) code:

// Create a Service instance 
            var service = new Service(Scheme.Https, "[my server]", 8000);
// Log in
            await service.LogOnAsync("user", "pass");

The program throws this error @ LogOnAsync:

{"'doctype' is an unexpected token. The expected token is '<!--' or '<[CDATA['. Line 1, position 3."}

As I understand it, this XML error can be thrown the there's no "doctype" (or XML at all), or sometimes if "doctype" isn't capitalized within the XML.

I will not be able to change the XML on the server side. Is there a way to disable the validation strictly within the SDK?

Thanks

Tags (4)
1 Solution

swbodie
Path Finder

I think you might be getting this error because you are hitting the wrong port number. Port 8000 is usually the web port and not the port that handles the web services management. I think you are getting this error because you are hitting the 8000 port which is returning the html of the page. Normally the first line of all HTML pages is !DOCTYPE html which would explain why its throwing the error. Try using the default web services port of 8089 and see if you get better results.

View solution in original post

ravi08402
New Member

i can access splunk over VPN only. so connected to VPN. and trying to login using thiS code
For the same
// Create a Service instance
var service = new Service(Scheme.Http, "[my server]", 8000);
// Log in
await service.LogOnAsync("user", "pass");

I am getting the Same error. At the ame time i am able to access via BrWoser. let me knoW if anything i missed

0 Karma

swbodie
Path Finder

I think you might be getting this error because you are hitting the wrong port number. Port 8000 is usually the web port and not the port that handles the web services management. I think you are getting this error because you are hitting the 8000 port which is returning the html of the page. Normally the first line of all HTML pages is !DOCTYPE html which would explain why its throwing the error. Try using the default web services port of 8089 and see if you get better results.

urbanwks
Engager

Thank you! Works perfectly!

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...