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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...