feedbin / feedbin-api

Feedbin API Documentation
349 stars 26 forks source link

Error 500 on POST to Subscriptions (aka Create Subscription) #18

Closed musashinm closed 8 years ago

musashinm commented 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? 😄

musashinm commented 8 years ago

Nevermind, I just changed the module urllib to requests and it works... Closing.