Skip to content Skip to sidebar Skip to footer

403 Error When Accessing Bit.ly Api To Shorten Url With Python

Here's the code I'm using: import re import sys import glob import json import requests import os from pprint import pprint if len(sys.argv) > 1: urls_json = sys.argv[1] el

Solution 1:

Just eliminate the group_guid:

payload = json.dumps({'long_url': u[1], "domain": "bit.ly" })

Despite being clearly indicated in the API documentation as one of the parameters. That returns a 201 for "Created"

Solution 2:

headers={'Authorization': f"Bearer {api_key}" }

should be

headers={'Authorization': f"{api_key}" }

Post a Comment for "403 Error When Accessing Bit.ly Api To Shorten Url With Python"