C
C#13mo ago
James

JsonException missing required properties when they are there

"contact_inbox": {
"id": 4,
"contact_id": 4,
"inbox_id": 1,
"source_id": "f7b6c095-1356-47dd-b7ba-58cee0531175",
"created_at": "2023-11-27T14:04:07.619Z",
"updated_at": "2023-11-27T14:04:07.619Z",
"hmac_verified": false,
"pubsub_token": "h18bNijnqfjVLtsTNd17hGPq"
}
"contact_inbox": {
"id": 4,
"contact_id": 4,
"inbox_id": 1,
"source_id": "f7b6c095-1356-47dd-b7ba-58cee0531175",
"created_at": "2023-11-27T14:04:07.619Z",
"updated_at": "2023-11-27T14:04:07.619Z",
"hmac_verified": false,
"pubsub_token": "h18bNijnqfjVLtsTNd17hGPq"
}
public sealed record ContactInbox
{
public required int Id { get; init; }
public required int ContactId { get; init; }
public required int InboxId { get; init; }
public required string SourceId { get; init; }
public required string CreatedAt { get; init; }
public required string UpdatedAt { get; init; }
public required bool HmacVerified { get; init; }
}
public sealed record ContactInbox
{
public required int Id { get; init; }
public required int ContactId { get; init; }
public required int InboxId { get; init; }
public required string SourceId { get; init; }
public required string CreatedAt { get; init; }
public required string UpdatedAt { get; init; }
public required bool HmacVerified { get; init; }
}
JsonException: JSON deserialization for type 'MultipanelChatwootServer.Dtos.ContactInbox' was missing required properties, including the following: id, contact_id, inbox_id, created_at, updated_at, hmac_verified
9 Replies
Jimmacle
Jimmacle13mo ago
are you trying to deserialize that exact json to that exact model? because they don't match the contact_inbox: at the beginning would be incorrect also, share any relevant deserializer configuration/code
James
JamesOP13mo ago
It wouldn't let me edit the post, I'm using:
private readonly JsonSerializerOptions _jsonOptions = new ()
{
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
};
private readonly JsonSerializerOptions _jsonOptions = new ()
{
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
};
Jimmacle
Jimmacle13mo ago
so again is that the entire json you're deserializing? because that doesn't represent a ContactInbox, it represents some other object with a ContactInbox property
James
JamesOP13mo ago
No it's not Let me try deserialise it alone Yes it is a property Okay it deserialised fine by itself
Jimmacle
Jimmacle12mo ago
yeah so something is probably wrong in whatever model contains this property
James
JamesOP12mo ago
No description
James
JamesOP12mo ago
No description
James
JamesOP12mo ago
The root object is this:
No description
James
JamesOP12mo ago
I believe the account deserialised fine
Want results from more Discord servers?
Add your server