1

I am trying to use the Frankfurter currency exchange rate API in my python program but it is returning InvalidChunkLength error or ChunkedEncodingError(e) error when I try to print the status code to confirm that the connection is established.

I have tried the suggestion in this answer and it did not work: requests - ChunkedEncodingError with requests.get, but not when using Postman

Here is my code:

import requests convert_from = str(input("Enter the currency to convert from: ")).upper() convert_to = str(input("Enter the currency to convert to: ")).upper() convert_amount= float(input("Enter the amount that you want to convert: ")) host = 'api.frankfurter.app' response = requests.get(f'https://{host}/latest?amount={convert_amount}&from={convert_from}&to={convert_to}') print(response.status_code) 

My error:

 Traceback (most recent call last): File "C:\Users\Mysystem\Desktop\PYTHON\MyProjects\currency\lib\site-packages\urllib3\response.py", line 748, in _update_chunk_length self.chunk_left = int(line, 16) ValueError: invalid literal for int() with base 16: b'' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\Mysystem\Desktop\PYTHON\MyProjects\currency\lib\site-packages\urllib3\response.py", line 443, in _error_catcher yield File "C:\Users\Mysystem\Desktop\PYTHON\MyProjects\currency\lib\site-packages\urllib3\response.py", line 815, in read_chunked self._update_chunk_length() File "C:\Users\Mysystem\Desktop\PYTHON\MyProjects\currency\lib\site-packages\urllib3\response.py", line 752, in _update_chunk_length raise InvalidChunkLength(self, line) urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read) 

...and a bunch of lines. Please note that when requests for just the api.frankfurter.app, it returns 200 as expected. Also, note that I am using a virtual environment on a Windows 11 machine.

Thank you for your help, I am pretty new to Python.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.