I've been trying to send data to an API in order for the API to persist an operation in a database. I couldn't do it and I can't find the solution to it. Please help.
Model Dto:
public class NewRentalDto
{
public int CustomerId { get; set; }
public List<int> MovieIds { get; set; }
}
Controller definition:
public IHttpActionResult NewRentals(NewRentalDto newRental){
//todo
}
Json objects sent through Postman:
Attempt 1:
{
"movieIds": [3,4]
,"customerId": 1004
}
Result: Exception
Attempt 2:
{
"MovieIds": [3,4]
,"CustomerId": 1004
}
Result: Exception
Attempt 3:
{
"Movieids": [3,4]
,"Customerid": 1004
}
Result: Exception
Attempt 5:
{
"customerId": 1004
,"movieIds": [3,4]
}
Result: Exception
I get the exception in the "todo" section of the controller when I try to access the newRental instance. This is the message I get:
{
"message": "An error has occurred.",
"exceptionMessage": "Object reference not set to an instance of an object."
//more error info
}