Help

Re: Bit.ly Link Shortener Script for automation

689 0
cancel
Showing results for 
Search instead for 
Did you mean: 
btg202
5 - Automation Enthusiast
5 - Automation Enthusiast

Hopefully useful for someone. If you set a variable called ‘Shorten’, then you can use this script to pull the URL and turn it into a bit.ly link which you can then use to automate something else! Feedback always welcome.

let inputConfig = input.config();
let response = await fetch('https://api-ssl.bitly.com/v4/shorten', {
    method: 'POST',
    headers: {
        'Authorization': 'API CODE FROM BITLY GOES HERE',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({ "long_url": inputConfig.Shorten, "domain": "bit.ly", "group_guid": "THIS CAN BE FOUND IN THE URL OF YOUR BITLY ACCOUNT" })
});
let bitly = await response.json()
output.set("bitly", bitly)
1 Reply 1
ninstar
4 - Data Explorer
4 - Data Explorer

Thanks. For some reason this isn't working for me. 

I copied/pasted it directly, make a shorten field, added the API key and the group_guide thingy. And entered it into the scripts automation. Please help!