I need to pass list object of class in restful web api. But i am receiving null
value in web api.
Below is my code in Web API.
Public class RequestDto
{
private string _clientId;
public string ClientId
{
get { return _clientId; }
set { _clientId= value; }
}
private List<DeliveryDocument> _deliveryDocumentInfo;
public List<DeliveryDocument> DeliveryDocumentInfo
{
get { return _deliveryDocumentInfo; }
set { _deliveryDocumentInfo = value; }
}
}
public class DeliveryDocument
{
public string DocumentName { get; set; }
public string DocumentURL { get; set; }
}
public HttpResponseMessage PostSaveManifest([FromBody] RequestDto manifestRequest)
{
//here i am receiving null value in list parameter
}
Below code for calling web api.
var values = new JObject();
values.Add("ClientId", "23824");
var DeliveryDocumentInfo = new List<DeliveryDocument>();
DeliveryDocumentInfo.Add(new DeliveryDocument { DocumentName = "Document Name", DocumentURL = "D:/Documnet/test.png" });
var serOut = JsonConvert.SerializeObject(DeliveryDocumentInfo);
values.Add("DeliveryDocumentInfo", serOut);
HttpContent content = new StringContent(values.ToString(), Encoding.UTF8, "application/json");
var responsesss = client.PostAsync(Constants.URLValue + "/api/Manifest", content).Result;