atlassian-python-api icon indicating copy to clipboard operation
atlassian-python-api copied to clipboard

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

Open cbertran opened this issue 1 year ago • 11 comments

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)

cbertran avatar Jul 19 '23 11:07 cbertran

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

gonchik avatar Aug 13 '23 19:08 gonchik

@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

gagbaghdas avatar Sep 19 '23 13:09 gagbaghdas

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

gonchik avatar Sep 25 '23 07:09 gonchik

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

Thanks!

gagbaghdas avatar Sep 26 '23 07:09 gagbaghdas

@sreway please help once you have some time

gonchik avatar Sep 26 '23 08:09 gonchik

@sreway please help once you have some time

Sure

gagbaghdas avatar Sep 27 '23 08:09 gagbaghdas

Any updates on this?

Stef16Robbe avatar Oct 31 '23 10:10 Stef16Robbe

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

SLRover avatar Nov 14 '23 10:11 SLRover

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

tianjing-li avatar Feb 07 '24 15:02 tianjing-li

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()

andurin avatar Jul 26 '24 14:07 andurin

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 protected]", "<api_token>")

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

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

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

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
  1. 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 = <page_id>
url = f"https://<company>.atlassian.net/wiki/api/v2/pages/{page_id}/properties"

auth = HTTPBasicAuth(<EMAIL>, <API KEY>)

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=(",", ": ")))

hidara2000 avatar Aug 09 '24 04:08 hidara2000