11

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?

cytsunny
  • 4,838
  • 15
  • 62
  • 129

2 Answers2

30

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!!

LMabley
  • 489
  • 5
  • 6
  • 4
    This. The value in the GUI under Group Settings > Advanced > API turns out to be the "group name". The above will give you the right values (look for "guid", not "organization_guid". Alternatively, your group id is in the URL when you're on the bit.ly GUI, e.g. `https://app.bitly.com/{*guid*}/bitlinks`. – ZAR Oct 26 '20 at 18:50
9

I have been looking around for these issues. Currently, my solution is by removing body group_guid and getting a response 201 (created). I hope my information helps.