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 · 1 comment
Open

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

Isaha-Miller opened this issue Nov 5, 2024 · 1 comment
Labels
bug Something isn't working

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
@PJ-Finlay
Copy link
Collaborator

I think the LibreTranslate API changed slightly. We had this issue with the Python API too. It's fixed in the Python API so maybe we can just copy code from there. If someone makes a pull request for this I'll merge it.

@PJ-Finlay PJ-Finlay added the bug Something isn't working label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants