C
C#2w 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
Angius2w ago
Why would your API return a Result like that?
Angius
Angius2w ago
No description
MODiX
MODiX2w ago
If you have no further questions, please use /close to mark the forum thread as answered
Nakama
NakamaOP2w 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.
Want results from more Discord servers?
Add your server