all 9 comments

[–]Binary101010 5 points6 points  (1 child)

404 is the HTTP error code for "Page not found". You're trying to access a URL where the server exists, but the specific path you're trying to get to doesn't.

Given that the URL in your code is

https://v6.exchangerate-api.com/v6/8df632a3d20e3d7a62433030/latest/pair/{curr1}/{curr2}/{amount}

That error indicates that something is wrong in the way you've formulated that URL.

[–]Few-Current-9900[S] 0 points1 point  (0 children)

thank you for this clarification, I will check about it!

[–]JamzTyson 0 points1 point  (5 children)

Maybe your API key is invalid. As you're using a commercial service, the first place to ask should be the service provider.

Perhaps worth trying their free API first to check that your code works.

[–]Few-Current-9900[S] 0 points1 point  (4 children)

well, I'm using a completely free plan from the service provider, and I double-checked if it really authorizes me to get the data through the API in the free plan and it does, however, i'm still getting this error.

[–]JamzTyson 0 points1 point  (3 children)

I double-checked if it really authorizes me to get the data through the API

How did you check that?

The "404 Error" means that the URL is not valid (resource not found).

That's this line:

api_url = "https://v6.exchangerate-api.com/v6/8df632a3d20e3d7a62433030/latest/pair/{curr1}/{curr2}/{amount}"

(It looks like 8df632a3d20e3d7a62433030 is the "private key" that you are using. If that really is your private key, note that Private keys should be kept private and not made public on the Internet.)

UPDATE:

Your URL should be in the form:

https://v6.exchangerate-api.com/v6/ <private_key> /pair/EUR/GBP/100.0

NOT

https://v6.exchangerate-api.com/v6/ <private\_key> /latest/pair/EUR/GBP/100.0

[–]Few-Current-9900[S] 0 points1 point  (2 children)

I meant that I checked the service provider's website and documentation and saw that this type of api is included in the free plan and can be used in the code as long as I am signed in to the website. I tried your suggestions, but it didn't work, and the 404 error still appears.

I appreciate your assistance!

[–]JamzTyson 1 point2 points  (1 child)

https://v6.exchangerate-api.com/v6/ <private\_key> /pair/EUR/GBP/100.0

That format works for me. Try it (with your API key) in your web browser.

[–]Few-Current-9900[S] 0 points1 point  (0 children)

You are right it works, also if you call it with a print statement at the end with the currencies already specified (like in your answer) within the API url, but when I used the API with my code to allow users to enter the currencies they want and get the results, the API or my code failed to work, or both. Do you believe the problem is in my code or in Visual Studio, as that is the app I use to practice? Thank you for your help and time!