I am trying to access a Rest API that supports GET, POST, PUT, MOVE functions. When I try the URL using the browser to get list of files I get a response from the REST API. However, when I try to call the same URL via requests.get(url) I get:
(Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x000002D8CCFBC6A0>, 'Connection to timed out. (connect timeout=None)'))
What am I missing? (if it makes any difference I am passing a JWT token within the URL)
#URL in the browser returns a list in JSON
#When calling the same URL via requests
import requests
url = https://www.restapi.com/content?JWT-token
x = requests.get(url)
print(x.status_code)
#Errors out: (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x000002D8CCFBC6A0>, 'Connection to <URL> timed out. (connect timeout=None)'))
CodePudding user response:
I am not expert in Python, but it looks like you forgot quotes for link, it should look like this:
url = 'https://wwww.restapi.com/content?JWT-token'
EDIT: Oh, you see, in your url you typed wwww instead of www. Is this ok?
CodePudding user response:
When you run the url within the browser it automatically finds the corresponding proxy for the url. I had to download the proxy file from browser's setting find the proxy mapping for that URL and add proxy parameters within the requests
CodePudding user response:
class Coordinates:
def distToPoint(self, p):
"""
Use pythagoras to find distance
(a^2 = b^2 c^2)
"""
...
def isNear(self, p):
distToPoint(self, p)
...