C
C#3mo ago
Nakama

GetFromJsonAsync and nested objects using FluentResults

I am working on a controller and service that uses FluentResults but I am running into some issues when returning objects inside of the result.
public async Task<Result<MemberDTO>> GetByIdAsync(ulong id)
{
var response = await _httpClient.GetFromJsonAsync<Result<MemberDTO>>($"api/Member/{id}");
return response!;
}
public async Task<Result<MemberDTO>> GetByIdAsync(ulong id)
{
var response = await _httpClient.GetFromJsonAsync<Result<MemberDTO>>($"api/Member/{id}");
return response!;
}
Whenever the above code is ran, the response contains the Result with the correct success message. But the Member itself which is stored in the value property is missing. The controller returns the correct object but even when I map it as a json it fails to do this and returns a null. I'm absolutely clueless what is causing this.
{
"isSuccess": true,
"value": {
"id": 489867864224956400,
"username": "NakamaTM",
"coins": 10,
"messageCount": 23,
"prayDate": null,
"vrcProfile": ""
},
"errors": [],
"successes": [
"Discord User fetched successfully"
]
}
{
"isSuccess": true,
"value": {
"id": 489867864224956400,
"username": "NakamaTM",
"coins": 10,
"messageCount": 23,
"prayDate": null,
"vrcProfile": ""
},
"errors": [],
"successes": [
"Discord User fetched successfully"
]
}
The response from the controller looks as follows.
5 Replies
Angius
Angius3mo ago
Why would your API return a Result like that?
Angius
Angius3mo ago
No description
MODiX
MODiX3mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Nakama
NakamaOP3mo ago
Ah that explains a lot. My understanding was that fluent results were supposed to be used through all layers. I will create a dto for it instead.

Did you find this page helpful?