I'm trying to make a request to the Bitly API using the code below but I am receiving a 422 error message. I'm not using OAuth as it seems this is not required for single account users such as myself.
The documentation isn't too clear on how to make a request in this scenario.
function bitly() {
var long_url = "https://stackoverflow.com/questions/ask";
var apiv4 = 'https://api-ssl.bitly.com/v4/shorten';
var genericAccessToken = "xxxxx";
var params = {
method: "post",
headers: {"Authorization" : "Bearer " + genericAccessToken,
"Content-Type": "application/json"},
payload: {"group_guid": "string",
"domain": "bit.ly",
"long_url": long_url},
};
var res = UrlFetchApp.fetch(apiv4, params);
var obj = JSON.parse(res.getContentText());
}