Closed musashinm closed 8 years ago
Hi folks,
I'm trying to create a new subscription in Python3, but I always get error 500.
import urllib.parse import urllib.request api = 'https://api.feedbin.com/v2/' manager = urllib.request.HTTPPasswordMgrWithDefaultRealm() manager.add_password( None, api, 'USERNAME', 'PASSWORD' ) handler = urllib.request.HTTPBasicAuthHandler( manager ) opener = urllib.request.build_opener( handler ) urllib.request.install_opener( opener ) data = urllib.parse.urlencode( { 'feed_url' : 'SOME_FEED_URL' } ).encode( 'utf-8' ) header = { 'Content-Type' : 'application/json; charset=utf-8' } url = api + 'subscriptions.json' request = urllib.request.Request( url, data, header ) try: response = urllib.request.urlopen( request ) except urllib.error.URLError as error: print( error ) else: response = response.read() print( response )
Could you give some help? 😄
Nevermind, I just changed the module urllib to requests and it works... Closing.
urllib
requests
Hi folks,
I'm trying to create a new subscription in Python3, but I always get error 500.
Could you give some help? 😄