Google URL Shortener API - Google URL Shortener API - curl curl

Google URL Shortener API -


This is a correct example and you probably did something else wrong. The API is working correctly and shortening the URL with your provided example.

Are you sure that you did not finish executing the command at the first backslash (\), because if you do that it would return with the error what you experiencing. Make sure you run the whole command at once. You can also join the multiple lines into one and remove the backslashes.

So running this command (without providing the content and the HTTP headers):

curl https://www.googleapis.com/urlshortener/v1/url?key=<MYAPIKEY>

Would return the following error:

{ "error": {  "errors": [   {    "domain": "global",    "reason": "required",    "message": "Required parameter: shortUrl",    "locationType": "parameter",    "location": "shortUrl"   }  ],  "code": 400,  "message": "Required parameter: shortUrl" }}