Blogger API v.3 - can't transfer the data to the post (javascript)

565 Views Asked by At

New post created with out data - http://yatsynych.blogspot.com/. Problem on object body_data?

My source:

function makeApiCallBlogger() {
    gapi.client.setApiKey('AIzaSyDFnBwpKVqjMm9NJ4L0Up5Y_bYpsaJdC6I');
    gapi.client.load('blogger', 'v3', function() {

        var body_data = {
            "kind": "blogger#post",
            "blog": {
                "id": "********"
            },
            "title": "A new post",
            "content": "With <b>exciting</b> content..."
        }

        var request = gapi.client.blogger.posts.insert({
            "blogId": '********',
            "body": body_data});

        request.execute(function(response) {
            alert(response.toSource());
        });

    });
}
1

There are 1 best solutions below

0
On

i have the same problem but thanks to this post Google Calendar.Insert API returning 400 'required' i solved.

you must create a "resource" key for the body.

you can try this

var request = gapi.client.blogger.posts.insert({
        "blogId": "****",
        "resource" : {
            "title" : "...",
            "content" : "...",
            "image" : {
                "url" : "..."
            }
        }
    });