Jenkins.NET icon indicating copy to clipboard operation
Jenkins.NET copied to clipboard

Update config lead jenkins Server Internal Error(500)

Open sunux opened this issue 5 years ago • 2 comments

server: CentOS + Jenkins 2.176.2 Client: Windows 10 x64

When call JenkinsNET.JenkinsClientJobs.UpdateConfiguration() returns with Server Internal Error, but posting the same config xml with postman works.

It seems WriteXml in UpdateConfiguration use UTF8(with BOM) as default encoding, Jenkins server cannot handle BOM. I change default encoding to UTF8(without BOM), update succeed, but all non-ascii characters became garbled.

After chaning WriteXml default encoding to AscII, garbled character was resolved. So should the default encoding be changed to AscII ?

sunux avatar May 13 '20 06:05 sunux

server : windows 2016 Standard Client : windows 2016 Standart or Win 10

I'm getting the same mistake. Is there a way to get through this?

protected void WriteXml(HttpWebRequest request, XNode node)
        {
            var xmlSettings = new XmlWriterSettings {
                ConformanceLevel = ConformanceLevel.Fragment,
                Indent = false,Encoding = Encoding.ASCII
            };

            using (var stream = request.GetRequestStream())
            using (var writer = XmlWriter.Create(stream, xmlSettings)) {
                node.WriteTo(writer);
            }
        }

siraykut avatar May 18 '21 13:05 siraykut

Probably better is: var xmlSettings = new XmlWriterSettings { ConformanceLevel = ConformanceLevel.Fragment, Indent = false, Encoding = new UTF8Encoding(false) };

IlyaAtGitHub avatar Sep 07 '21 18:09 IlyaAtGitHub