Scenario 2:
Testing the endpoint with an invalid activity level
Prod:
import requests prod_url = 'https://wikimedia.org/api/rest_v1/metrics/editors/by-country/en.wikipedia/50..99-edits/2020/12' header = {"accept": "application/json", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"} response = requests.get(prod_url, headers=header) print(response.status_code) print(response.json())
This returns 400 status code and the json:
{'type': 'https://mediawiki.org/wiki/HyperSwitch/errors/bad_request', 'title': 'Invalid parameters', 'method': 'get', 'detail': "data.params['activity-level'] should be equal to one of the allowed values: [5..99-edits, 100..-edits]", 'uri': '/wikimedia.org/v1/metrics/editors/by-country/en.wikipedia/50..99-edits/2020/12'}
Local:
This returns 400 status code and the json error:
Traceback (most recent call last): File "/Users/emekachukwukere/PycharmProjects/pythonProject1/venv/lib/python3.9/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, **kwargs) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/emekachukwukere/PycharmProjects/pythonProject1/editors/test_local_editors_by_country.py", line 14, in <module> print(response.json()) File "/Users/emekachukwukere/PycharmProjects/pythonProject1/venv/lib/python3.9/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)