Google URL Shortner cURL returns error

149 Views Asked by At

I have a API Key and tried to use it for shortening URL. If I shorten google.com then I get shorten url

curl https://www.googleapis.com/urlshortener/v1/url?key=MYKEY  -H 'Content-Type: application/json' -d '{"longUrl": "www.google.com"}'

{
 "kind": "urlshortener#url",
 "id": "shorten url",
 "longUrl": "http://www.google.com/"
}

But if I use other URLs like yahoo.com then returns the error

curl https://www.googleapis.com/urlshortener/v1/url?key=MYKEY  -H 'Content-Type: application/json' -d '{"longUrl": "www.yahoo.com"}'
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "Forbidden"
   }
  ],
  "code": 403,
  "message": "Forbidden"
 }
}

Not sure why?

0

There are 0 best solutions below