Post to w/draft

Posted by, Last update 7 months ago


7 months ago

better title for the script

Update to the original Post to script. First time running this action, you will need to provide an app token generated from your profile at
When you run this script you’ll get a question if the post is a draft. If so, you’ll be redirected to the edit-screen, otherwise the post is published.


  • script

      post to hosted account
      using Micropub API
    // First run, you will be prompted for
    // App Token. Generate tokens on the
    // Account page
    var credential = Credential.create("", "Insert app token generated on account page.");
    credential.addTextField("apptoken", "App Token");
    var appToken = credential.getValue("apptoken");
    // Does it draft?
    let p = Prompt.create();
    p.addSwitch("select-post-status", "Is it a draft", false);
    if (p.fieldValues["select-post-status"] == true) {
    	var poststatus = "draft";
    } else {
    	var poststatus = "publish";
    // Setup API and content 
    var endpoint = ""
    var content = draft.content
    // create and post HTTP request
    var http = HTTP.create();
    var response = http.request({
      "url": endpoint,
      "method": "POST",
      "encoding": "form",
      "data": {
        "h": "entry",
        "content": content,
    	"post-status": poststatus
      "headers": {
        "Authorization": "Bearer " + appToken
    var results = JSON.parse(response.responseText);
    if(poststatus != "draft"){
    console.log("Response: " + response.statusCode);
    if (response.statusCode != 200 && response.statusCode != 202) {;


  • After Success Nothing
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.