I have two Web APIs built using .Net Core 3.1
I am trying to pass a model which has 2 different Lists as properties. Though the method in the 2nd API is called successfully from the 1st API, the properties of the model i.e. lists are null.
There is no issue with the API call as i could pass and receive the value when i called a method with a string as input parameter.
Here is my code
1st API method :
public async Task SomeMethod(MyModel Input, string resource)
{
var client = new ServiceClient(BaseUrl)
{
Resource = resource,
};
client.Post(Input);
}
resource here is the url for 2nd API Method
Model :
public class MyModel
{
public List<Class1> List1;
public List<Class2> List2;
}
2nd API:
[Route("v1/myservice")]
[ApiController]
public class MyController : ControllerBase
{
private readonly IMyHandler _myHandler;
private readonly ILogger _logger;
private string _MyDestinationPath;
public MyController (IMyHandler myHandler, IConfiguration configuration, ILogger logger)
{
_myHandler= myHandler;
_MyDestinationPath = configuration.GetValue<string>("DestinationPath");
_logger = logger;
}
[HttpPost, Route("API2Method"), ResponseType(typeof(string))]
public async Task API2Method([FromBody]MyModel Input)
{
if(!ModelState.IsValid)
{
return;
}
}
}
Can someone point out what i need to change to receive the lists i am passing to the 2nd API instead of null