C# · 12月 26, 2021

c# – 将正文添加到与天蓝服务一起使用的HttpWebRequest mgmt api

我将如何添加到HttpWebRequest的正文?

身体需要由以下组成

<?xml version=”1.0″ encoding=”utf-8″?><ChangeConfiguration xmlns=”http://schemas.microsoft.com/windowsazure”> <Configuration>base-64-encoded-configuration-file</Configuration> <TreatWarningsAsError>true|false</TreatWarningsAsError> <Mode>Auto|Manual</Mode></ChangeConfiguration>

任何帮助深表感谢

解决方法 byte[] buf = Encoding.UTF8.GetBytes(xml);request.Method = “POST”;request.ContentType = “text/xml”;request.ContentLength = buf.Length;request.GetRequestStream().Write(buf,buf.Length);var HttpWebResponse = (HttpWebResponse)request.GetResponse();