Hi there,
While accessing the v3 Shorten API, I am getting a MISSING_ARG_ACCESS_TOKEN response no matter what I try. The access_token is correct, and the URL is encoded. I have confirmed this by accessing the api via a web link with my access token and a test URL.
data: {"access_token":<access_token>,"longUrl":"http%3A%2F%2F<host><endodedparams>","format":"txt"}
bitly response: { "data": [ ], "status_code": 500, "status_txt": "MISSING_ARG_ACCESS_TOKEN" }
Does anything jump out in the code below that could be causing the error? Many thanks!
function shortenURL(accessToken : String, request : CurrentRequest) {
var _timeout = '3000';
var host = 'api-ssl.bitly.com';
var endpt = '/v3/shorten';
var url : String = request.httpURL;
var data : String = JSON.stringify({
access_token : accessToken,
longUrl : encodeURIComponent(url),
format : 'txt'
});
var httpClient : HTTPClient = new HTTPClient();
httpClient.setTimeout(_timeout);
httpClient.open('GET', 'https://' + host + endpt);
httpClient.send(data);
if ( httpClient.statusCode != 200 ) {
throw new Error('HTTP Communication error : Status code ' + httpClient.statusCode + ' - ' + httpClient.statusMessage);
}
var bitlyURL = JSON.parse(httpClient.text);
return bitlyURL;
};
[ allResponseHeaders=null, errorText=null, statusCode=0, statusMessage=null, text=null
httpClient.open('GET', 'https://api-ssl.bitly.com/v3/shorten?access_token=' + accessToken +'&longUrl=' +encodeURIComponent(url) + '&format=txt');
bitly response: { "data": [ ], "status_code": 500, "status_txt": "MISSING_ARG_ACCESS_TOKEN" }
var httpClient : HTTPClient = new HTTPClient();
httpClient.setTimeout(_timeout);
httpClient.open('GET', 'https://api-ssl.bitly.com/v3/shorten');
httpClient.send('?access_token=' + accessToken +'&longUrl=' +encodeURIComponent(url) + '&format=txt');
Any more ideas?