I have xml which I send by API in another resurse. I create it by XDocument:
XDocument xDoc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("Entity",new XAttribute("Type", "attribute1"),
new XElement("Fields",...
When I put it in the request it has sent without declaration. So I do next:
StringBuilder builder = new StringBuilder();
TextWriter writer = new StringWriter(builder);
using (writer)
{
xDoc.Save(writer);
}
But now TextWriter change encoding in xml to utf-16. I need to change it again on utf-8.