I would like to create a WebAPI endpoint which accepts an object that contains a property for documents that can be attached. This endpoint should cater for JSON and XML requests, and not sure how to get this working. I have looked around but cannot find a good example to the spec I am looking for. Please see below the type of solution I need assist with please:
Model Objects:
public class User
{
public User(){
Documents = new List<Document>();
}
public int UserId {get;set;}
public string FirstName {get;set;}
public string LastName {get;set;}
public string Employee {get;set;}
public List<Document> Documents {get;set;} //e.g. Identity Document, Certifications etc
}
public class Document{
public int DocumentId {get;set;}
public string Name {get;set;}
public string Extension {get;set;}
public byte[] Data {get;set;}
}
WebAPI Controller EndPoint:
[HttpPost]
public IHttpActionResult(User user){
... WHAT TYPE OF CODE DO I NEED HERE ...
}
The main question is how does a client also post to this endpoint, if please you can provide me with an example? Is my model object correct? How can data be posted from the client side using an xml request since the byte array data is not compatible xml?