简体   繁体   中英

Getting HTTP 502 on calling a time taking REST API using Python requests.post() method while same is working fine with REST client

I am calling a REST API which takes long time in processing like 2 minutes in python code using requests.post() method and getting HTTP 502 error in response. But calling same is working fine with different REST clients. What could be the possible reasons? Following code has been used to call the API:

res = requests.post(url, proxies=proxies, headers=myheaders, data=data.encode('utf-8'), timeout=1000)

But for small inputs it works from python but not from long input. For big inputs it is giving HTTP 502 error. But everything is working fine with REST clients. What would be the possible point of error?

I faced similar issue and found out that the issue was caused not because of the request body but as a result of the response body being too big.

I was using GraphQL to request data for the whole day and it kept on giving me 502 error. However, when I changed my request to provide the data only for 12 hours, it was successful in python.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM