Issue with attaching an existing file while creating node using RESTWS I am trying to create a new node using the restws drupal module. My content type has just two fields: title and a file. However, when i send the request with following payload, i get an error. The file which i am referring in the payload is already existing on my drupal server.

URL : CMS_BASE_URL/node
Method : POST

Payload:

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;data&gt;
      &lt;field_my_file&gt;
                &lt;file resource="file" id="24"&gt;CMS_BASE_URL/file/24&lt;/file&gt;
      &lt;/field_my_file&gt;
      &lt;type&gt;filetest&lt;/type&gt;
      &lt;title&gt;My 1st file test&lt;/title&gt;
      &lt;language&gt;en&lt;/language&gt;
      &lt;author resource="user" id="5"&gt;
      &lt;/author&gt;
&lt;/data&gt;


Error - 406 Not Acceptable: Invalid data value given. Be sure it matches the required data type and format.

Is there any problem in the way i am sending the payload? If i remove the "file" part from the payload, it is able to create node.Please guide me if this is not correct.
I tested the following code it works fine. Replace your field machine names and bundle name accordingly. Hope it helps

Here is the XML format to send data

&lt;result&gt;
&lt;title&gt;title_of_node&lt;/title&gt;
&lt;type&gt;sampleimage&lt;/type&gt;
&lt;field_samplefile&gt;
&lt;und is_array="true"&gt;
&lt;item&gt;
&lt;fid&gt;18&lt;/fid&gt;
&lt;uid&gt;1&lt;/uid&gt;
&lt;filename&gt;Drupal.txt&lt;/filename&gt;
&lt;uri&gt;public://Drupal.txt&lt;/uri&gt;
&lt;filemime&gt;text/plain&lt;/filemime&gt;
&lt;/item&gt;
&lt;/und&gt;
&lt;/field_samplefile&gt;
&lt;/result&gt;


Here is the JSON format

{
    "title": "title_of_node",
    "type": "bundle_name",
    "field_samplefile": {
        "und": [{
            "fid": "17",
            "filename": "changes.txt",
            "uri": "public://changes.txt",
            "filemime": "text/plain"
        }]
    } 
}