Save to Pinboard

Hi everyone, I’ve been trying to hack together a script to save an URL to Pinboard by butchering Add Pinboard Note but it’s just been timing out with no URL saved… I am a complete newbie at Javascript so I suspect this is just me simply not understanding how JS is actually properly written. Will be very grateful to any gurus out there who has some time for suggestions!

// See online documentation for examples

// Drafts | Where Text Starts

// get username and password from credentials

var credential = Credential.create(“Pinboard”, “Allow Login to the Pinboard Site for Requests. ONLY USE FOR ACTIONS NOT COVERED BY THE PINBOARD API”)

credential.addTextField(“username”, “Username”);

credential.addPasswordField(“password”, “Password”);

credential.authorize();

http = HTTP.create()

var response = http.request({

    'url': 'https://pinboard.in/auth/',

    'method': 'POST',

    'data': {

        'username': credential.getValue('username'),

        'password': credential.getValue('password')},

    'encoding': 'form'

        

})

var response2 = http.request({

    'url': 'https://pinboard.in/add/',

    'method': 'POST',

    'data': {

        'url': [[draft]],

        'toread': yes,

        'tags': drafts,

        'submit': 'save_ ' + set_private,

        'action': 'save_' + set_private

        },

    'username': credential.getValue('username'),

    'password': credential.getValue('password'),

    'headers': {'User-Agent': 'Drafts for IOS'},

    'encoding': 'form'

    })

    

console.log(response.statusCode);

console.log(response.responseData);

console.log(response2.statusCode);

console.log(response2.responseData);

API documentation here: https://pinboard.in/api/

Can’t post it previously as there is a posting limit for URLs for new forum joiners.