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);
});
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With