rshar
rshar

Reputation: 1475

Internal server error while passing parameters in API endpoint URL in Python 3.7

I would like to perform a GET operation to an API endpoint. Following is the base URL.

#GET /v{version}/lists/{list-id}/terms/{term-id}/preferred-name

url = "https://abcd.eu/v{version}/lists/{list-id}/terms/{term-id}/preferred-name"
headers = {'Accept': 'application/json'}

params = {'version': '1', 'list-id': '102', 'term-id': '103'}

r = requests.get(url, auth=('ghfgdhg', 'hgdfhghd'), params = params)
print(r.text)

However, I am getting an internal server error. Any help is highly appreciated.

Upvotes: -1

Views: 49

Answers (1)

Rozto_
Rozto_

Reputation: 73

Internal server error usually means the server could not process what you have given it

I recommend trying the API running with postman first (or any other rest client) to try if it functions

If everything works I would try to construct the url (and not use params) like this:

version, list_id, term_id = '1', '102', '103'

url = f"https://abcd.eu/v{version}/lists/{list_id}/terms/{term_id}/preferred-name"
headers = {'Accept': 'application/json'}

r = requests.get(url, auth=('ghfgdhg', 'hgdfhghd'), headers=headers)

Upvotes: 1

Related Questions