URL and customMetaData option in Blogger API

徘徊边缘 提交于 2020-01-05 04:23:12

问题


I am creating posts using Blogger API.

In documentation of Blogger API: https://developers.google.com/blogger/docs/3.0/reference/posts

In resource representation of Posts, I am interested in 2 columns: url and customMetaData

Property name     Value     Description 
url               string    The URL where this post is displayed. 
customMetaData    string    The JSON metadata for the post.

I am able to set title and content, but URL and Search Description are not working.

I want to send Search Description in customMetaData, but I don't know the structure of JSON required as nothing such is given in documentation.

My Code:

  var postUrl = "https://www.googleapis.com/blogger/v3/blogs/blogId/posts";
  postUrl = postUrl.replace("blogId",blogId);
  var options = {
    method:"post",
    contentType:"application/json",
    headers: { Authorization: "Bearer "+ ScriptApp.getOAuthToken()},
    muteHttpExceptions: true,
    payload: JSON.stringify({
      title: title,
      content: content,
      url: url,
      customMetaData: JSON.stringify({
        description: description
      })
    })
  }
  var res = UrlFetchApp.fetch(postUrl, options).getContentText();
  Logger.log(res)

来源:https://stackoverflow.com/questions/59503028/url-and-custommetadata-option-in-blogger-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!