How to use JSON API to update a specific value in a multi-value field?

Created on 8 January 2024, 5 months ago
Updated 24 January 2024, 5 months ago

Problem/Motivation

I'm investigating how to use JSON API to update a single value within an entity's multivalue field.

Is that possible using JSON API without using PATCH method to replace all of the values within a multivalue field with previous and changed
values?

Using a simplytest.me Drupal Umami Recipe content as an example.
/jsonapi/node/recipe/1ccd8b1b-b09b-405c-ad44-e1aadb1bc880?fields[node--recipe]=field_ingredients

{"jsonapi":{"version":"1.0","meta":{"links":{"self":{"href":"http:\/\/jsonapi.org\/format\/1.0\/"}}}},"data":{"type":"node--recipe","id":"1ccd8b1b-b09b-405c-ad44-e1aadb1bc880","links":{"self":{"href":"https:\/\/master-6hplc6fufbi9r9qm4cpm32byiowejoz4.tugboatqa.com\/en\/jsonapi\/node\/recipe\/1ccd8b1b-b09b-405c-ad44-e1aadb1bc880?resourceVersion=id%3A40"}},"attributes":{"field_ingredients":["For the pastry:","280g plain flour","140g butter","Cold water","For the filling:","1 onion","2 garlic cloves","Half a courgette","450ml soya milk","500g grated parmesan","2 eggs","200g sun dried tomatoes","100g feta"]}},"links":{"self":{"href":"https:\/\/master-6hplc6fufbi9r9qm4cpm32byiowejoz4.tugboatqa.com\/jsonapi\/node\/recipe\/1ccd8b1b-b09b-405c-ad44-e1aadb1bc880?fields%5Bnode--recipe%5D=field_ingredients"}}}

How would I update the second value "280g plain flour" without using PATCH to send all of the other unchanged values?

πŸ’¬ Support request
Status

Fixed

Version

10.2 ✨

Component
JSON APIΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΊπŸ‡ΈUnited States jasonawant New Orleans, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024