I'm integrating an app with ZenDesk. They have a REST API. I need to send POX in the request body. I'm using the WCF REST Starter Kit.
How do I programmatically add my xml to the request body?
Here's my unit test:
[Test]
public void Can_create_user()
{
// Arrange
http = new HttpClient("http://myapp.zendesk.com/");
http.TransportSettings.Credentials = new NetworkCredential("[email protected]", "passW0rd");
http.DefaultHeaders.Accept.Add("application/xml");
var form = new HttpUrlEncodedForm();
var expectedStatusCode = 201;
var request = new XDocument(
new XElement("user",
new XElement("email", "[email protected]"),
new XElement("name", "Joe User"),
new XElement("roles", "4"),
new XElement("restriction-id", "4")));
form.Add("body", request.ToString());
// Act
var response = http.Post("users.xml", form.CreateHttpContent());
var content = response.Content.ReadAsString();
// Assert
response.EnsureStatusIs(expectedStatusCode);