Update config lead jenkins Server Internal Error(500)
Opened this issue · 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 ?
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);
}
}
Probably better is:
var xmlSettings = new XmlWriterSettings {
ConformanceLevel = ConformanceLevel.Fragment,
Indent = false,
Encoding = new UTF8Encoding(false)
};