I'm trying to implement error-handling of 504 responses for my Requests statement when I query an API. I read through this question, and am attempting to implement the solution given in the most-voted answer.
My code keeps failing with the error get() takes 2 positional arguments but 3 were given
. In my code (below), I'm only passing get()
two arguments, though. Where am I going wrong?
Here's the full error TraceBack:
Exception has occurred: TypeError
get() takes 2 positional arguments but 3 were given
File " ... ", line 113, in my_function
s.get("https://epqs.nationalmap.gov/v1/json", payload)
File " ... ", line 158, in <module>
d = my_function(l)
TypeError: get() takes 2 positional arguments but 3 were given
My code:
payload = {
"x": coordinate[0],
"y": coordinate[1],
"wkid": 4326,
"units": "Meter",
"includeDate": "false",
}
s = requests.Session()
retries = Retry(
total=10,
backoff_factor=1,
status_forcelist=[502, 503, 504],
)
s.mount("https://", HTTPAdapter(max_retries=retries))
s.get("https://epqs.nationalmap.gov/v1/json", payload)
My previous code that didn't make use of Session()
or mount()
worked, so does Session()
add some data behind the scenes to the get()
request that I'm overlooking?
Here's my previous code, fwiw:
payload = {
"x": coordinate[0],
"y": coordinate[1],
"wkid": 4326,
"units": "Meter",
"includeDate": "false",
}
r = requests.get("https://epqs.nationalmap.gov/v1/json", payload)