1

For example, I have this URL

https://store.epicgames.com/es-ES/p/dead-island-2--gold-edition

@app.get("/Datos/{CI}")
async def read_CI(CI: str):
    return{"CI_Datos":CI}```

This is my curl

curl -X 'GET' \
'http://127.0.0.1:8000/Datos/%2F%2F' \
-H 'accept: application/json' 

and I want the API to be able to get that URL.

I get error 404 when I pass a URL. I understand that the problem is the /.

Chris
  • 18,724
  • 6
  • 46
  • 80
elaadani
  • 21
  • 4
  • You need to urlencode it – mousetail Aug 26 '22 at 20:27
  • If you are looking for how to pass a URL as a path parameter, please have a look at [this answer](https://stackoverflow.com/a/72815364/17865804). If you would instead like to pass it as a query parameter, please take a look [here](https://stackoverflow.com/a/72068032/17865804). – Chris Aug 27 '22 at 04:31

1 Answers1

1

After a little research, I have a solution:


@app.get("/Datos")
async def get_url(
    url: str = None
):
    return {"url": url}


elaadani
  • 21
  • 4