I have the following url:

http://localhost:8000/api/v1/open/?name=/ficheiro#.txt

and I want to get it's information via a GET request (using python's Requests lib). That "/ficheiro#" is the "name" parameter of the object I want to get. What happens is that the url is not recognized and so it returns nothing to the GET request, eventhough such object exists!

Anyone knows what might be going on?

Thanks in advance

有帮助吗?

解决方案

Escape the # symbol in urls with an encoded pound symbol (%23). In your case, http://localhost:8000/api/v1/open/?name=/ficheiro%23.txt.

The # character is a special character, called a named anchor, that isn't passed to the server by the browser. In your case (assuming everything else works fine), the browser is requesting the file "/ficheiro", not "/ficheiro#.txt"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top