Skip to content

[Confluence] api_root arg in class Confluence() is not used. #744

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

Closed
sonr09 opened this issue Mar 18, 2021 · 4 comments
Closed

[Confluence] api_root arg in class Confluence() is not used. #744

sonr09 opened this issue Mar 18, 2021 · 4 comments

Comments

@sonr09
Copy link

sonr09 commented Mar 18, 2021

Following REAS API doc: https://docs.atlassian.com/ConfluenceServer/rest/7.11.1/#api/content/{id}/child-childrenOfType
Client can make requests with context and without:
Example with context: http://example.com:8080/confluence/rest/api/space/ds
Example without context: http://confluence.myhost.com:8095/rest/api/space/ds

Following code, I found that this is possible to define via arg api_root in parent for class Confluence.
But this arg not used after that. So client can request only for hard coded api root = 'rest/api/'.

p.s. I have to idea why Atlassian provided requests with context and without :)

@dotcs
Copy link

dotcs commented Mar 27, 2021

I've experienced the same problems. I'm wondering if it would be sufficient to rewrite code parts that contain hardcoded rest/api such as

url = "rest/api/content/{page_id}/child/{type}".format(page_id=page_id, type=type)

into

url = self.resource_url("content/{page_id}/child/{type}".format(page_id=page_id, type=type))

The resource_url function is defined in as follows:

def resource_url(self, resource, api_root=None, api_version=None):
if api_root is None:
api_root = self.api_root
if api_version is None:
api_version = self.api_version
return "/".join(s.strip("/") for s in [api_root, api_version, resource] if s is not None)

I also noticed that it's not only the confluence module that has the problem, but also others, e.g.

resource = "rest/api/latest/plan/{}".format(plan_key)

url = "rest/api/2/mypermissions"

Also in the bitbucket module the logic looks differently and the string is hard coded depending on the url:

if "cloud" in kwargs:
kwargs["api_root"] = "" if "api.bitbucket.org" in url else "rest/api"

How is the general idea here? I could probably write a PR but would like to first understand how this should be implemented best. Maybe one of the maintainers of this package can help?

@sonr09
Copy link
Author

sonr09 commented Mar 29, 2021

@dotcs thank you for comment.

I don't know cases that would be use api_root. I've just noted that api_root not used in confluence module and I've saw that confluence REST API has something which called context.

If somebody find cases for using api_root (especially in Confluence module), PR will have place.

@Spacetown
Copy link
Contributor

I was also wondering about the construct in bitbucket. I think this is a difference between private cloud instances which use the rest/api and the atlassian instance which use another server name.

@gonchik
Copy link
Member

gonchik commented Mar 28, 2025

Hi!
let's revise if it's needed, for now I see it's better to keep for now

@gonchik gonchik closed this as completed Mar 28, 2025
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

4 participants