1

I am trying to figure out what the format and required parameters are for an update request to a field collection via the Services Module's REST API. I have installed the Services Entity API Module to allow interaction via Services with additional entity types.

I was able to save to a field collection when I first set everything up, using a PUT request, the CSRF token and properly formatted JSON.

{"field_fivestar_value":[
      {
         "rating":"100",
         "target":"0"
      }
   ]
}

which gave me this to access: field_fivestar_value['und'][0]['value'] which seemed to work perfect in the past, but now it seems that something is interfering/wrong as i get a notice after submitting a PUT request that $revision_id and/or $field_name aren't set, which never happened before...

2 Answers 2

1

It appears that something to do with revisions is causing the problem as if I provide specific (required?) data in my PUT request it works. Working PUT request JSON:

{
    "field_primary_aircraft": {
        "und": [
            {
                "value": "1"
            }
        ]
    },
    "field_name": "field_aircraft",
    "item_id": "5929",
    "revision_id": "5929",
    "default_revision": true,
    "field_aircraft_registration": {
        "und": [
            {
                "value": "testing12355"
            }
        ]
    }
}

That JSON plus a working CSRF token allowed me to save data back to a field collection that is part of a users Profile2 profile.

The revision_id and default_revision were the trickiest parts to track down and supply, I don't have revisions enabled as far as I can tell also, so why this problem started suddenly I have no idea...at least it is solved and hopefully this info helps someone else.

0

This sandbox will implement a field_collection service for services 3.x: https://www.drupal.org/sandbox/graber/2141747

Work is still in progress for entity api support for field _collections here: https://www.drupal.org/node/2044833

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.