Dashboards & Visualizations

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

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

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

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

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

Engager

Thank you! Works perfectly!

0 Karma
Don’t Miss Global Splunk
User Groups Week!

Free LIVE events worldwide 2/8-2/12
Connect, learn, and collect rad prizes
and swag!