I was wondering if I can get some help with a problem I'm having.
I'm using requests to pull some data from an api for a web app that I'm deploying on Heroku. On my local computer I have no problem connecting to the API and pulling data down, but when I deploy to Heroku it won't work. (The same thing happens when I try testing on Cloud 9 IDE)
Example Code below:
import requests
email = 'example@example.com'
url = 'https://api.example.com/'
auth = ('example', 'example')
headers = {'Accept': 'application/json', 'content-type': 'application/json'}
params = {'emailaddress': email}
r = requests.get(url+'customer.svc/search', params=params, auth=auth, headers=headers)
It's very basic, but I just can not get it to work.
Everytime I try to connect I get the error:
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /customer.svc/search?emailaddress=example%40example.com (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
I'm new to Heroku, so this might be prety basic. What am I missing?
Edit:
It seems the error only happens when I deploy my code. I've tried the code on several machines and I have no trouble with the request. I wonder if it has something to do with the connection back to my Heroku app?