I need help adding a file to a node. I am using the media and media:youtube modules for creating links to youtube videos. My field is called field_practice. I am using the Rest Console to test adding a file. Ultimately I want to add the file when the node is created. Currently I am trying to use the PUT method to update an existing node. This current scenario is not working with an existing node:417.

Request URI:
http://nextgametime.com/app/node/attach_file/417

Content Type:
application/json

Raw Body:
{"field_practice":{"und":[{"fid":"data4.fid","filename":"Trae Jefferson", "uri":"https://youtu.be/w4vYTBzWXkg", “filemime”:”video/youtube”,"type":"video","display":"1"}]}}

Please help so that I can add a file to a node on creation and the ability to add a file when updating a node. Thanks.

Comments

promardi created an issue. See original summary.

promardi’s picture

Issue summary: View changes
tyler.frankenstein’s picture

Priority: Critical » Normal
Status: Active » Closed (works as designed)

You have to send an integer value for the fid. Here's a complete example: http://tylerfrankenstein.com/code/drupal-services-file-create-example-js...

promardi’s picture

Thank you Tyler. Your support is appreciated. I will review your answer and keep you posted on the outcome.