httphttprequestbit.ly

Bit.ly bitlink creation always return forbidden even after email verification?


I have registered and done email verification. Then, I try the most baisc API trying to shorten a testing link. The following is my HTTP packet.

POST /v4/shorten HTTP/1.1
Host: api-ssl.bitly.com
Content-Type: application/json
Authorization: Bearer my-generic-access-token
Cache-Control: no-cache

{
"group_guid": "shorten_link_testing",
"domain": "mytesting.site.com",
"long_url": "http://mytesting.site.com/"
}

And the following is the return from bit.ly:

{
    "message": "FORBIDDEN",
    "resource": "bitlinks",
    "description": "You are currently forbidden to access this resource."
}

I am using Postman to test, so I am quite sure it is not the problem of my code. And the message format meets that in the documentation of bit.ly, so at least the connection is success. As far as I know, bit.ly should have 10,000 quota for free shorten link per month for every account, right? What have I missed so that I am banned from the shorten link service?


Solution

  • The group_guid param needs to reference the id of a group associated with your bitly account. Hit this api endpoint with your generic access token to get a list of the groups/guids bitly has associated with your account: GET https://api-ssl.bitly.com/v4/groups.

    Apparently the domain param is optional, because your account may have a default domain associated with it. It worked for me after removing the domain param altogether. https://groups.google.com/forum/#!topic/bitly-api/9RywN3ETLkg

    Hope this helps!!