adventurous-addition-28416
04/25/2025, 3:46 AMError calling CreateIdentity: {"error":{"code":400,"status":"Bad Request","request":"f120f58b-5c6f-421a-b3e2-cf839f616adb","message":"json: unknown field \"organization_id\""}}
at Ory.Kratos.Client.Api.IdentityApi.CreateIdentityWithHttpInfoAsync(KratosCreateIdentityBody kratosCreateIdentityBody, Int32 operationIndex, CancellationToken cancellationToken)
at Ory.Kratos.Client.Api.IdentityApi.CreateIdentityAsync(KratosCreateIdentityBody kratosCreateIdentityBody, Int32 operationIndex, CancellationToken cancellationToken)
at EndUser.Api.Features.EndUser.CreateEndUser.CreateEndUserEndpoint.HandleAsync(CreateEndUserRequest request, IDocumentStore store, CancellationToken cancellationToken) in C:\dev\EndUser.Api\Features\Enduser\CreateEndUser\CreateEndUserEndpoint.cs:line 104
brief-egg-61061
04/25/2025, 3:46 AMbrief-egg-61061
04/25/2025, 3:46 AMorganization_id
field when creating an identity using the Ory Kratos Admin API. The error message "json: unknown field \"organization_id\""
suggests that the SDK or API version you're using doesn't recognize the organization_id
field in the request body. This could be due to using an older version of the Ory Kratos client that doesn't support this field yet. Looking at the GitHub issue you're experiencing, this appears to be a known issue. According to [this GitHub issue](https://github.com/ory/network/issues/347), there are some fields in the response from the /admin/identities
endpoint that might be unset or not properly handled. To resolve this issue, you could try: 1. Updating your Ory Kratos client to the latest version, as the organization_id
field might be supported in newer versions. 2. If you're using a custom model to deserialize the response, make sure it matches the current API schema. 3. Remove the organization_id
field from your request if you don't specifically need it for your use case. Here's an example of a valid identity creation request based on the documentation: csharp var createIdentityBody = new KratosCreateIdentityBody( schemaId: "<preset://basic>", // or your custom schema ID traits: new Dictionary<string, object> { { "email", "<mailto:user@example.com|user@example.com>" }, // other traits according to your schema } // Don't include organization_id if your client version doesn't support it ); var identity = await apiClient.IdentityApi.CreateIdentityAsync(createIdentityBody);
If you need to use the organization_id
field specifically, you might need to update your client SDK to the latest version that supports this field.adventurous-addition-28416
04/25/2025, 3:51 AMvar endUserIdentity = await oryIdentityApi.CreateIdentityAsync(new KratosCreateIdentityBody(
new KratosIdentityWithCredentials(
password: new KratosIdentityWithCredentialsPassword(
config: new KratosIdentityWithCredentialsPasswordConfig(password: request.Password))),
schemaId: "default",
state: KratosCreateIdentityBody.StateEnum.Active,
traits: new
{
name = request.Name.Trim().ToUpper(),
email = request.Email,
cellPhone = $"+{endUserCellPhone.CountryCode}{endUserCellPhone.AreaCode}{endUserCellPhone.Number}",
brazilianSocialSecurityNumber =
endUserBrazilianSocialSecurityNumber.Value,
gender = request.Gender,
}), cancellationToken: cancellationToken);
brief-egg-61061
04/25/2025, 3:51 AMbrief-egg-61061
04/25/2025, 3:51 AMCreateIdentityAsync
method with a KratosCreateIdentityBody
object. 2. You're setting up password credentials, schema ID, state, and traits properly. 3. The traits you're including (name
, email
, cellPhone
, brazilianSocialSecurityNumber
, and gender
) need to match your schema definition. For reference, here's how the Ory documentation shows creating an identity with credentials: go CreateIdentityBody := *ory.NewCreateIdentityBody( "default", // schema_id map[string]interface{}{ "email": "<mailto:user@example.com|user@example.com>", "name": map[string]string{ "first": "foo", "last": "bar", }, }, )
[Ory Kratos SDK Go](https://www.ory.sh/docs/kratos/self-hosted/go#use-identity-management-api) A few recommendations: 1. Make sure your default
schema includes all the traits you're providing (name, email, cellPhone, etc.) 2. If you're encountering issues, you might want to try the simpler approach shown in the documentation examples first, then add complexity. 3. Ensure your traits match exactly what's defined in your schema, as Kratos validates traits against the schema. If you're still encountering the "unknown field organization_id" error from your previous question, make sure you're using the latest version of the Ory Kratos client that supports all the fields you're using.