using facebook batch request javascript api
api, batch-file, facebook, javascript, request
Solution
Like Sharon said, you need to put the body field in a url encoded way.
You can do it simple with jquery, like:
var opts = {
message : 'Some message',
name : 'Post Name',
link : 'url',
description : 'The post Description',
picture : 'url to image'
};
FB.api('/', 'POST', {
batch: [
{ method: 'GET', relative_url: 'me/friends'},
{ method: "POST",relative_url: "me/feed", body : $.param(opts) }
]
}, function (response) {
console.log(response);
});
Works good.
Problem
Im trying to send batch request to graph api, and getting error in the response for the second request: ``` "{ "error": { "message": "(#100) Missing message or attachment", "type": "OAuthException", "code": 100 } }" ``` Can anyone tell me what am I doing wrong? Here is the code I use: ``` var opts = { message : 'Some message', name : 'Post Name', link : 'url', description : 'The post Description', picture : 'url to image' }; FB.api('/', 'POST', { batch: [ { method: 'GET', relative_url: 'me/friends'}, { method: "POST",relative_url: "me/feed", body : opts } ] }, function (response) { console.log(response); }); ```