Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 17 post data to dotnet core8. Json deserialisation of bool failed #1163

Open
1988gadocansey opened this issue Apr 15, 2024 · 1 comment

Comments

@1988gadocansey
Copy link

MacOS ventura (M1)
Dotnet 8
Angular 17

---> Microsoft.AspNetCore.Http.BadHttpRequestException: Failed to read parameter "CreateBiodataRequest command" from the request body as JSON.
---> System.Text.Json.JsonException: The JSON value could not be converted to System.Nullable`1[System.Boolean]. Path: $.residentialStatus | LineNumber: 0 | BytePositionInLine: 451.
---> System.InvalidOperationException: Cannot get the value of a token type 'String' as a boolean.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedBoolean(JsonTokenType tokenType)

the json is below.

{
"id": 1,
"firstName": "MM",
"lastName": "MM",
"title": "0",
"previousName": "OCANSEY",
"otherName": "N",
"phone": "0243348522",
"altPhone": "0243348522",
"noOfChildren": 12,
"day": "4",
"year": "2005",
"month": "2",
"maritalStatus": "0",
"gender": "0",
"email": "[email protected]",
"emergencyContact": "0243348522",
"hometown": "CAPE COAST",
"postGprs": "OCANSEY",
"district": "1",
"nationalIDType": "0",
"nationalIDNo": "12",
"regionId": "1",
"nationalityId": "2",
"residentialStatus": "true",
"disability": "true",
"disabilityType": "0",
"sourceOfFinance": "OCANSEY",
"religionId": "1",
"denomination": "1",
"referrals": "Print Media",
"sponsorShipCompany": "",
"sponsorShipLocation": "",
"sponsorShipCompanyContact": "",
"guardianName": "OCANSEY",
"guardianPhone": "0243348522",
"guardianOccupation": "OCANSEY",
"guardianRelationship": "PARENT",
"languages": [
"2"
]
}

@Arun25980
Copy link

the issue is with the json object.
u can follow this
https://stackoverflow.com/questions/75089603/system-text-json-how-to-convert-from-true-to-boolean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants