atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.36k stars 664 forks source link

[Confluence] Does not use the v2 version of the api-rest #1200

Open cbertran opened 1 year ago

cbertran commented 1 year ago

According to Change-Log many functions of Confluence rest api v1 will stop working, and if I'm not mistaken, these libraries use api-rest version 1 (/wiki/rest/api/ instead of /wiki/rest/api/v2)

gonchik commented 1 year ago

@cbertran that's right, I will wrap up the cloud version as rest/api/v2

gagbaghdas commented 1 year ago

@cbertran that's right, I will wrap up the cloud version as rest/api/v2 Hi there . Is there any approx estimation on this? Thanks

gonchik commented 1 year ago

@gagbaghdas I did not started yet, I little bit busy

gagbaghdas commented 1 year ago

@gagbaghdas I did not started yet, I little bit busy

Thanks!

gonchik commented 1 year ago

@sreway please help once you have some time

gagbaghdas commented 1 year ago

@sreway please help once you have some time

Sure

Stef16Robbe commented 1 year ago

Any updates on this?

SLRover commented 1 year ago

We start working. Currently, new API version will be released as beta. We will providing new methods as soon as possible.

tianjing-li commented 9 months ago

@SLRover Any further updates? Will moving the Confluence python SDK to your V2 API introduce any breaking changes to the existing methods?

andurin commented 3 months ago

Would also love to see this - creating confluence pages for example is literally broken. I guess other methods based on the content endpoints too.

Right now Confluence Cloud answers with a rude requests.exceptions.HTTPError: com.atlassian.confluence.api.service.exceptions.PermissionException: Could not create content with type page after confluence.create_page()

hidara2000 commented 3 months ago

For what it's worth - 2 hacky workarounds. Works for me but USE AT YOUR OWN RISK

  1. Create a new page using the raw requests module and then use the atlassian-python-api library to update the page using the page ID returned in the response
    
    # This code sample uses the 'requests' library:
    # http://docs.python-requests.org
    import requests
    from requests.auth import HTTPBasicAuth
    import json

url = "https://{your-domain}/wiki/api/v2/pages"

auth = HTTPBasicAuth("email@example.com", "")

headers = { "Accept": "application/json", "Content-Type": "application/json" }

payload = json.dumps( { "spaceId": "", "status": "current", "title": "", "parentId": "", "body": { "representation": "storage", "value": "" } } )

response = requests.request( "POST", url, data=payload, headers=headers, auth=auth )

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

2. Change the editor version manually for existing pages (had some minor issues with some widgets being full width eg tables)

This code sample uses the 'requests' library:

http://docs.python-requests.org

import requests from requests.auth import HTTPBasicAuth import json

page_id = url = f"https://.atlassian.net/wiki/api/v2/pages/{page_id}/properties"

auth = HTTPBasicAuth(, )

headers = { "Accept": "application/json" }

payload = json.dumps( { "key": "editor", "value": "v2", } )

response2 = requests.request( "post", url, data=payload, headers=headers, auth=auth )

print(json.dumps(json.loads(response2.text), sort_keys=True, indent=4, separators=(",", ": ")))