Estoy intentando consumir una API REST utilizando python, pero al momento de hacer el llamado me muestra el siguiente error:
Connection aborted.', error(110, 'Connection timed out')
Mi codigo es el siguiente:
# -*- coding: iso-8859-1 -*-
import requests, sys, time, os, json, datetime,shutil, os
reload(sys)
sys.setdefaultencoding('iso-8859-1')
url_detalle_cliente = 'https://187.180.213.123:8087/services/v0/customers?documentTypeId=DNI&documentNumber=10203040&expand=classifications,contact-details,indicators'
datajson = {}
datajson['time_raw'] = time.strftime("%Y/%m/%d %H:%M:%S")
datajson['url_detalle_cliente'] = url_detalle_cliente
servicio_response_status_code = 0
servicio_response_total_seconds = 0
#Get Token
command = 'python generarToken.py'
os.system (command)
# Read Token
f = open ('token.txt','a')
f.close()
f = open ('token.txt')
tsec = f.read()
f.close()
try:
HEADERS={
'Content-Type':'application/json',
'tsec':tsec
}
response = requests.get('https://148.244.45.194/PFCC_PR_01/customers/v0/customers?documentTypeId=DNI&documentNumber=10203040&expand=classifications,contact-details,indicators', headers=HEADERS)
if(response is None):
data['error_message'] = "Ocurrió un error en el servicio"
else:
servicio_response_status_code = str(response.status_code)
servicio_response_total_seconds = response.elapsed.total_seconds()
if(response.status_code == 202):
datajson.update(response.json())
except Exception, e:
datajson['error_message'] = str(e)
datajson['servicio_response_status_code'] = servicio_response_status_code
datajson['servicio_response_total_seconds'] = servicio_response_total_seconds
json_data = json.dumps(datajson)
print(json_data)
Cuando ejecuto el archivo .py me devuelve el error de timeout. Cuando pruebo el servicio en un postman me recupera la data sin problemas. No estoy seguro si el problema es por el protocolo https.
Espero puedan ayudarme