I have very limited exprerience in MVC, WebAPI,C# etc. I was asked to create a controller that contains a method that receives an HttpRequest (XML) and responds with back with an HttpResponse
I have come up to this state and I am confused:
[HttpPost]
[Consumes("application/xml")]
public async HttpResponseMessage ChannelUpload(HttpRequestMessage request)
{
using (var reader = new StreamReader(
request.Body,
encoding: Encoding.UTF8,
detectEncodingFromByteOrderMarks: false)
)
{
string bodyString = await reader.ReadToEndAsync();
string confirmation = ImportRequest(bodyString);
//Response
return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(confirmation) };
}
}
I do not know whether the parameter of the method is the correct (is HttpRequest valid?).
I do not know how to respond (CreateResponse() is not found)
Thank you in advance!