I need to add files to multiple value file field using drupal rest api (restws module). return format of restws is something like this :

"field_files": [

        "file": {
            "uri": "http://drupal/file/445",
            "id": "445",
            "resource": "file"

but when I send it to http//drupal/node/<node_id> restws returns not acceptable.

Can anyone suggest which format I must use to send data to?

and second question : How can I upload files using restws module ?

  • 1
    Never tried restws module but you can try to json_encode your string and try to add .json to the URL ... – drcelus Feb 25 '13 at 10:48
  • I've worked with drupal services module without problems, but for some reasons I've switched to restws, I can edit a node with one file but solution not working when node have more than one file. – KiT O Feb 25 '13 at 15:13

For my first question: I'm sending data with this format and it works now


      "fid": "445"


Where fid is the id of an existing and accessible file.

For my second question, I've written module extending restws classes that user can submit data like the way user submits for services rest api.

Idea behind my module is that user submits data and module checks validation data and if data is valid saves file using drupal file_save_data function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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