Skip to content

Deserializer: Cannot deserialize included, independent HasOne #349

Closed
@jaredcnance

Description

@jaredcnance

If you try to deserialize a json:api document that includes a resource identifier object (RIO) that points from the independent side of the relationship to the dependent side, you will get the following error:

JsonApiDotNetCore.Internal.JsonApiException : Failed to deserialize request body
---- JsonApiDotNetCore.Internal.JsonApiException : Permissions does not contain a foreign key property 'RoleId' for has one relationship 'Role'

example:

{
   "data":{
      "type":"independents",
      "id":"4a129a19-bcf3-42f5-f229-08d5edf8dba5",
      "attributes":{
      },
      "relationships":{
         "dependents":{
            "data":{
               "type":"dependents",
               "id":"730bfc72-df9b-4193-de01-08d5edf8dba0"
            }
         }
      }
   }
}

Instead it should instantiate the dependent side and set the value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions