I am trying to shorten the 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 is he requesting a short url? What am I doing wrong?
source share