Click here to Skip to main content
15,905,232 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have a api look like this:-

public async Task<IActionResult> testapi([FromForm] testdto _testdto)
    var abc = _testdto;
    return Ok();


and my model look like this:-

public class testdto
    public List<mylist> _mylist { get; set; }
public class mylist
    public string  num { get; set; }
    public string status {get; set; }

i am passing value like thta:-

  "num": "test",
  "status" : "success"

i call my api through swagger and pass values in mylist but i am unable to get those value. it always show count 0. can any one suggest me the solution

What I have tried:

i convert List into array but still got same result.
Updated 25-Oct-22 23:39pm
Graeme_Grant 26-Oct-22 4:37am    
yep, you set the response to null, so no values are returned. Here:
Response response = null;
TCS54321 26-Oct-22 5:03am    
it's just a dummy code. here i did not get value in _testdto when u call my API
Graeme_Grant 26-Oct-22 5:18am    
I agree with the other comments below.
GuyThiebaut 26-Oct-22 5:08am    
Can you show us the actual text you supply swagger with for testdto?

I imagine you should be passing in an array of strings, something like this:
TCS54321 26-Oct-22 5:36am    
i am passing values like that:
"num": "test123"

check the updated question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900