We've noticed that field name overrides are not being respected when issuing PATCH requests against the API when updating content. For example:

If our data is NOT using field name overrides, we would update it with a PATCH request looking something like this:

{
  "data": {
    "type": "my_type",
    "id": "84accc31-09f9-4c4e-bca2-511f5f0b0171",
    "attributes": {
      "name": "My Content",
      "field_data_1": "Some updated text Content",
    }
  }
}

This updates correctly.

However, if we modify the field name - in this instance just removing the Drupalism of 'field_data_1' and calling the field 'data_1'....

{
  "data": {
    "type": "my_type",
    "id": "84accc31-09f9-4c4e-bca2-511f5f0b0171",
    "attributes": {
      "name": "My Content",
      "data_1": "Some updated text Content",
    }
  }
}

Sending this patch request returns an error:

"The provided field (data_1) does not exist in the entity with ID 84accc31-09f9-4c4e-bca2-511f5f0b0171."

Comments

logickal created an issue. See original summary.

mrjmd’s picture

It's worth noting that POSTs seem to work fine.

e0ipso’s picture

Hmm this may be a bug in jsonapi then. The parent is not triggering the field name translation?

logickal’s picture

Yes, it's probably worth noting that the stack trace starts at jsonapi/src/Controller/EntityResource.php:219.

EDITED: Line number from stack trace, wrong copy paste.

logickal’s picture

Status: Active » Closed (works as designed)

Definitely applied to jsonapi - closing this issue to open in the appropriate place.