I solved the REST client issue by adding a content-type=application/xml in the header and the following line at the top of the body.
<ns2:device xmlns:ns2="networkdevice.rest.mgmt.acs.nm.cisco.com">
So now I am back to the C#. I get an error 400 code when running the following. I can do a GET without an error but it doesn't like my POST. Anyone with experience with this?
Uri address = new Uri("https://" + server + "/Rest/Identity/User");
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
request.PreAuthenticate = true;
request.Credentials = new NetworkCredential(_username, _password);
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
request.Method = "POST";
request.MediaType = "xml";
request.ContentType = "application/xml";
request.Accept = "application/xml";
StringBuilder data = new StringBuilder();
data.Append("<ns2:user ");
data.Append("name='" + "testUser" + "' ");
data.Append("description='" + "test desc" + "' ");
data.Append("identityGroupName='" + "All Groups:Network Administrator" + "' ");
data.Append("changePassword='" + "false" + "' ");
data.Append("enablePassword='" + "thisisalso!apass" + "' ");
data.Append("password='" + "thisisa!pass" + "' ");
data.Append("passwordNeverExpires='" + "false" + "' ");
data.Append("passwordType='" + "Internal Users" + "' ");
data.Append("enabled='" + "true" + "' ");
data.Append("/ns2:user>");
byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
request.ContentLength = byteData.Length;
using (Stream postStream = request.GetRequestStream())
{
postStream.Write(byteData, 0, byteData.Length);
}
response = request.GetResponse() as HttpWebResponse;