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

GET categories/<slug> does not work #15

Closed
maxpumperla opened this issue Feb 15, 2019 · 2 comments
Closed

GET categories/<slug> does not work #15

maxpumperla opened this issue Feb 15, 2019 · 2 comments

Comments

@maxpumperla
Copy link

Sorry for referring to the underlying HTTP API again, but in the end this is just a wrapper. I'm using Python to demonstrate my point. If I use:

# Get category for slug
slug = 'subpage'
version = 'v1.0'
url = host + "/api/v1/categories/" + slug
headers = {'x-readme-version': version}
response = requests.request("GET", url, headers=headers, auth=auth)
print(response.text) 

That will result in an error message, although the page exists and has a category. I can even confirm this by reading slug details for the same doc:

# Get doc/slug details WORKS
slug = 'subpage'
version = 'v1.0'
url = host + "/api/v1/docs/" + slug
headers = {'x-readme-version': version}
response = requests.request("GET", url, headers=headers, auth=auth)
print(response.text)
details = json.loads(response.content)
category = details.get('category')

so either I'm doing something fundamentally wrong or the endpoint doesn't work as expected

@domharrington
Copy link
Member

domharrington commented Feb 15, 2019

I think there's maybe a misunderstanding here of what this endpoint is supposed to do.

/api/v1/categories/slug - returns with the category object associated to that category slug

/api/v1/docs/slug - returns with the doc object associated to the doc slug (which will return with the category id required to update the doc)

The category slug isn't typically surfaced by default in the UI, but it can be useful if you wanted to built a wrapper around the API using the category slugs instead of using the ids.

Edit: As mentioned in here, that's probably work that should be done via this module so you can safely use category slugs: https://readmeio.canny.io/feature-requests/p/make-export-and-import-formats-consistent. The reason why we didn't do that originally was due to potential ambiguity with what to do when new categories are created vs existing categories being renamed/deleted.

@maxpumperla
Copy link
Author

@domharrington thank you. note that as a workaround I'm perfectly happy with my second option above, document details:

category = details.get('category')

that works well to retrieve the "category slug" from a "document slug".

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

2 participants