I am trying to fetch some data from an API. However, I getting below error.
Max retries exceeded with url: /api/search?accept=application/json&Authorization=Bearer......
I am trying following lines of code in python.
token = 'aagagagagagagagaggagagag'
def get_val (ont, term):
#set the url
url = 'https://host:port/api/search'
#set the header
Authorization = 'Bearer ' token
header = {
'accept': */*,
'Authorization': Authorization,
}
#set the parameters
params = {'ontology': ont, 'q': term, 'header':header}
#send request
response = requests.get(url, header)
get_val('mesh', 'ibu')
Following is the curl command (through wrapper):
curl -X 'GET' \
'https://host:port/api/search?from=0&ontology=mesh&q=ibu&size=10' \
-H 'accept: */*' \
-H 'Authorization: Bearer ''
Any help is highly appreciated.
CodePudding user response:
You are not passing your params
to requests.get()
so the API probably has a problem returning the correct data and your request fails.
Try to use:
requests.get(url, params=params, headers=header)
CodePudding user response:
Adding 'verify=False' in get function could provide the API response.