Action

Add to Readwise

Posted by @th1nkful, Last update over 2 years ago

Add the content of your Draft as to your Readwise account in the Quotes book

Steps

  • script

    // See online documentation for examples
    // https://docs.getdrafts.com/docs/actions/scripting
    
    const credential = Credential.create("Readwise", "Insert access token generated on Readwise at: https://readwise.io/access_token");
    
    credential.addTextField("apptoken", "Access Token");
    credential.authorize();
    
    const appToken = credential.getValue("apptoken");
    
    const http = HTTP.create();
    
    const response = http.request({
      "url": "https://readwise.io/api/v2/highlights/",
      "method": "POST",
      "encoding": "json",
      "data": {
        "highlights": [
          {
            "text": draft.content
          }
        ]
      },
      "headers": {
        "Authorization": "Token " + appToken
      }
    });
    
    if (response.error) {
     context.fail(response.error);
    }
    
    

Options

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