Problem attaching files to nodes with Services I'm trying to attach files (images) to nodes via Services 3 from an external app using JavaScript.

From what I understand (and doing) is:

1) Create a node posting JSON to my endpoint domain.com/api/node.json

{
  "type":"foo",
  "title":"Hello World",
  "language":"und",
  "body":{"und":{"0":{"value":"Body Text"}}},
}


2) Create file posting JSON to my endpoint domain.com/api/file.json

{
  "filename":"image.jpg",
  "target_uri":"public://image.jpg",
  "filemime":"image/jpeg",
  "file":"myBase64String"
}


No problem at all at this point.

Then when trying to attach the files created to the node, is where I have trouble, not http errors, simply nothing happens.

First I have tried posting JSON to my endpoint domain.com/api/node/*nid/attach_file after successfully creating a new file, and getting back the fid

{
  "field_name":"foo",
  "filename":"image.jpg",
  "fid":"*fid"
}


Returning Status 200 OK empty text, but when viewing the node remains the same without the file attached.

I have also tried to create the files first and then when posting for node creation adding the fid, the node is created but no file attached.

{
  "type":"foo",
  "title":"Hello World",
  "language":"und",
  "body":{"und":{"0":{"value":"Body Text"}}},
  "field_foo":{"und":{"0":{"fid":"*fid"}}}
}


My field is a field type Image, widget Image. I have also tried in another field type file, with same results.

If someone can give me a heads up, what am I doing wrong or what is missing. I can't find any explanatory documentation on line.

Thank you.
try adding more data to the attached file (it might be that fid and filename is not enough I can't find the example I used a long time ago, which had a similar problem):


alt (might be required in general or only if marked as required in bundle)
title (might be required in general or only if marked as required in bundle)
uid
filemime
uri
status = 1
display = 1


Some references I could find quickly:


https://stackoverflow.com/questions/5129559/attaching-image-files-to-nodes-programmatically-in-drupal-7
this answer: https://stackoverflow.com/a/19930610/1158887
https://drupal.stackexchange.com/questions/120078/is-it-safe-to-reuse-the-fid-file-id