Tuesday, April 21, 2015

Multifield - Add value using web service

One little checkbox...that's all it took. Something I didn't understand, but now do just a little better.

Here we are:

  1. Using Multifield module
    1. Multifield is defined as Unlimited Number of values
  2. Using Services with REST server to update a node - adding a value in the list of Multifields
  3. Using Postman to PUT to update that node
  4. Content type name: test_multi
  5. Multifield field name: field_jarod_multi
  6. Multifield subfield name: field_jarod_note, Integer
Here's what the Multifield config looks like by default for jarod_multi:
Note the checkbox is on for "Hide blank items". So when editing a node we see this:
That's fine. If I want to add another, I just use the button and we're good.
BUT it doesn't work when adding another through web services. Doing a PUT will give me a return code of 200, but the value is never added.

To do that, uncheck the "Hide blank items" button which gives a view like this when editing a node:
Now in my web services I do a PUT:

The full value for the Key is 
node[field_jarod_multi][und][2][field_jarod_note][und][0][value]

After the PUT, I get the new multifield value added to the node:

Lots of headaches over this one. I just missed the checkbox.  So glad this one is solved.