Reputation: 17614
I have created a webapi as follow
public OatherResponse Post([FromBody] List<Oather> oather)
{
Note that OatherResponse
and Oather
both are classes having some property.
Now I am trying to test this using simple html as below
<form method="post" action="http://localhost:50813/api/RegisterOather">
<input type="text" name="oather[0].OatherName" id="oather[0].OatherName" value="a3VsZGVlcA==" />
<input type="text" name="oather[1].OatherName" id="oather[1].OatherName" value="a3VsZGVlcA==" />
<input type="submit" value="Click Here" />
</form>
OatherName
is a string
property in Oather
class. But I always get count of oather
as zero.
Am I missing something.
Upvotes: 0
Views: 52
Reputation:
The name attribute values should be
name="[0].OatherName"
name="[1].OatherName"
Upvotes: 1