I create a REST server with Drupal 7, set everything and it work correctly, node created well, but I want to fill File field with REST.
my client side code is the following.
(function($){
function getCsrfToken(callback) {
jQuery.get(('http://example.com//services/session/token'))
.done(function (data) {
var csrfToken = data;
callback(csrfToken);
});
}
function postNode(csrfToken, node) {
jQuery.ajax({
url: 'http://example.com/rest/node',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': csrfToken
},
data: JSON.stringify(node),
success: function (node) {
console.log(node);
}
});
}
var newNode = {
type:'video',
title: 'Example node title3',
body: {
und: {
0: {
value :"Body"}
}
},
field_url:{
und: {
0: {
value :"http://url.com"
}
}
},
field_video:{
???????
}
};
getCsrfToken(function (csrfToken) {
postNode(csrfToken, newNode);
});
})(jQuery);
How can I pass a file (or an image) to REST service? what should I write instead of ?????
?