Thank you Mansilla. It worked. Also, now I am creating space using REST API and I get 400 error.
This is sample code I am using from the API docs.
This code sample uses the ‘requests’ library:
import requests
from requests.auth import HTTPBasicAuth
import json
url = “https://sushrutikarthik.atlassian.net/wiki/rest/api/space”
auth = HTTPBasicAuth(“email@gmail.com”, “api-key”)
headers = {
“Accept”: “application/json”,
“Content-Type”: “application/json”
}
payload = json.dumps( {
“key”: “”,
“name”: “”,
“description”: {
“plain”: {
“value”: “”,
“representation”: “”
}
},
“permissions”: [
{
“subjects”: {
“user”: {
“results”: [
{
“type”: “known”,
“username”: “”,
“userKey”: “”,
“accountId”: “”,
"email": "<string>",
"publicName": "<string>",
"profilePicture": {
"path": "<string>",
"width": 2154,
"height": 2154,
"isDefault": True
},
"displayName": "<string>",
"operations": [
{
"operation": "administer",
"targetType": "page"
}
],
"details": {},
"personalSpace": {
"id": 2154,
"key": "<string>",
"name": "<string>",
"type": "<string>",
"status": "<string>",
"_expandable": {},
"_links": {}
},
"_expandable": {
"operations": "<string>",
"details": "<string>",
"personalSpace": "<string>"
},
"_links": {}
}
],
"size": 2154
},
"group": {
"results": [
{
"type": "group",
"name": "<string>",
"_links": {}
}
],
"size": 2154
},
"_expandable": {
"user": "<string>",
"group": "<string>"
}
},
"operation": {
"operation": "administer",
"targetType": "page"
},
"anonymousAccess": True,
"unlicensedAccess": True
}
]
} )
response = requests.request(
“POST”,
url,
data=payload,
headers=headers,
auth=auth
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(“,”, ": ")))
###Output I get is:
{
“data”: {
“authorized”: true,
“errors”: [
{
“message”: {
“args”: ,
“translation”: “Invalid space key: ”
}
}
],
“successful”: false,
“valid”: false
},
“message”: “com.atlassian.confluence.api.service.exceptions.BadRequestException: Cannot create Space”,
“statusCode”: 400
}
Looks like example code has not been updated. Could you please guide me how to proceed in this area?