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

Root API url without trailing slash location is missing in resource URL #11

Closed
dspechnikov opened this issue Jul 23, 2018 · 2 comments
Closed

Comments

@dspechnikov
Copy link

How to reproduce

  1. Initialize API url with root URL with a location segment, but without trailing slash, i.e.:
API(api_root_url='https://test.loc/api')
  1. Add a resource.
  2. Invoke any method of the resource.

Expected result

I expect one of 2 options:

  1. A resource URL uses root URL with trailing slash (i.e. https://test.loc/api/resource).
  2. An exception is raised pointing to wrong configuration.

I like the first one a lot better. If there are any objections, please shout.

Actual result

A resource URL without root URL path is used, i.e. https://test.loc/resource.

Root cause

This line.

@dagostinelli
Copy link

This isn't working for me. I'm getting double-slashes on all my API URLs now. My resource URLs all start with a slash so that I can use absolute paths. Now that simple-rest-client is appending a slash to the root URL, I get double slashes. The result is a 404 every time.

class MyResource(Resource):
	actions = {
		'make_apple': {'method': 'GET', 'url': '/orchard/make_apple'},
	}
simple_rest_client.exceptions.NotFoundError: ("operation=not_found_error, response=Response(url='http://127.0.0.1:5000//orchard/make_apple', method='GET', body={'error': 404, 'text': '404 Not Found: The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.'}

The work around is to remove the leading slash on all the resources (pain).

(A little while ago, I upgraded from PyPI and received this change in there. )

@allisson allisson reopened this Nov 21, 2018
@allisson
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants