Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

language() request needs to be 'GET' in APIS.py #449

Open
Isaha-Miller opened this issue Nov 5, 2024 · 0 comments
Open

language() request needs to be 'GET' in APIS.py #449

Isaha-Miller opened this issue Nov 5, 2024 · 0 comments

Comments

@Isaha-Miller
Copy link

urllib is throwing a urllib.error.HTTPError: HTTP Error 405: METHOD NOT ALLOWED error because languages() is not specifying a GET request. The fix is to change line 82 req = request.Request(url, data=url_params.encode()) to an explicit GET.

def languages(self):
        """Retrieve list of supported languages.

        Returns: A list of available languages ex. [{"code":"en", "name":"English"}]
        """

        url = self.url + "languages"

        params = dict()

        if self.api_key is not None:
            params["api_key"] = self.api_key

        url_params = parse.urlencode(params)

        req = request.Request(url, data=url_params.encode(),method="GET")

        response = request.urlopen(req)

        response_str = response.read().decode()

        return json.loads(response_str)```
@Isaha-Miller Isaha-Miller changed the title language request needs to be 'GET' in APIS.py language() request needs to be 'GET' in APIS.py Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant