webapiclientgen: Cannot implicitly convert type 'System.Net.Http.HttpResponseMessage' to 'Newtonsoft.Json.Linq.JObject'
Hi - thanks for this nice project 😃
I have an API controller with an action like this:
[HttpGet("distribution")]
public async Task<dynamic> GetDistribution()
When running client code gen the result is this - and this will not compile:
/// <summary>
/// GET api/Statistics/distribution
/// </summary>
public async Task<Newtonsoft.Json.Linq.JObject> GetDistributionAsync()
{
var requestUri = new Uri(this.baseUri, "api/Statistics/distribution");
var responseMessage = await client.GetAsync(requestUri);
try
{
responseMessage.EnsureSuccessStatusCode();
return responseMessage;
}
finally
{
responseMessage.Dispose();
}
}
Thanks.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (10 by maintainers)
WebApiClientGenCore 3.8 released.
.NET Core has some special treatment toward async Task<dynamic>, different from the behavior of .NET Framework. Not really hard to resolve such difference.
I had just found the problem, when the service function is decorated with async Task, the generated codes is incorrect.