SumoLogic/sumologic-python-sdk

collectors endpoint is broken if you have / on end of endpoint

rickjuryxero opened this issue · 2 comments

when I call the collectors endpoint with this sdk it fails with a 500. I believe this might be because there are // in the url for example: https://api.us2.sumologic.com/api/v1//collectors

if I try to get back a list of collectors or access a single collector I now get an error where this worked up till a month or so ago.

sumo.collectors()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/rick.jury/.local/share/virtualenvs/sumologic-api-tools-f4YSK5be/lib/python3.6/site-packages/sumologic/sumologic.py", line 99, in collectors
    r = self.get('/collectors', params)
  File "/Users/rick.jury/.local/share/virtualenvs/sumologic-api-tools-f4YSK5be/lib/python3.6/site-packages/sumologic/sumologic.py", line 53, in get
    r.raise_for_status()
  File "/Users/rick.jury/.local/share/virtualenvs/sumologic-api-tools-f4YSK5be/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: {"id":"YGMEC-MMS5N-UZJ1K","errors":[{"code":"internal.error","message":"Internal server error."}]} for url: https://api.us2.sumologic.com/api/v1//collectors

ok you can close this I realised this only happens if you define the endpoint with a trailing / e.g endpoint='https://api.us2.sumologic.com/api/v1/' instead of: endpoint='https://api.us2.sumologic.com/api/v1'

That's right @rickjuryxero. I am adding a validation against a trailing slash in #40. Thanks for bringing it up.