I'm trying to shorten a URL using the http://goo.gl
API with the following jQuery function
$.ajax({
url: 'https://www.googleapis.com/urlshortener/v1/url?key=MY_API_KEY',
crossDomain: true,
type: 'POST',
contentType: 'application/json',
data: '{longUrl:"'+encodeURI(url)+'"}',
dataType: 'jsonp',
success: function(e) {
alert(JSON.stringify(e));
}
});
And I get the following Error in JSON :
{"error":{"errors":[{"domain":"global","reason":"required","message":"Required parameter: shortUrl","locationType":"parameter","location":"shortUrl"}],"code":400,"message":"Required parameter: shortUrl"}}
Why does it ask for a Short URL? What am I doing wrong?