How do i get space key from spaceid in confluence server

Kshitij Katiyar April 21, 2022

I am Getting the Space id from the webhook payload created using the REST APIS given .Refer to this doc :-https://docs.atlassian.com/ConfluenceServer/rest/7.2.0/#api/webhooks-createWebhook

Webhook Payload :-

{
"timestamp": 1650607676259,
"event": "space_updated",
"userKey": "XXXXXXXXXXXXX",
"space": {
"id": XXXXXX,
"creatorKey": "XXXXXXXXXX",
"creationDate": 1648588938819,
"lastModifierKey": "XXXXXXX",
"modificationDate": 1650607676259
}
}

 

Now to Get the other Information about the Space I need the space key . Using Rest APIs how can i get the space key and other informations about the space from spaceid.

2 answers

1 vote
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 22, 2022

Hi @Kshitij Katiyar ,

you should get all spaces through http://example.com/confluence/rest/api/space?limit=100 (please use a limit based on the number of your spaces) and find your space based on id and then take the key.

Currently there are no other rest apis.

Fabio

Kshitij Katiyar January 7, 2025

@Fabio Racobaldo _Herzum_  Is there any better way than getting all the spaces?

0 votes
Sebastian Krzewiński
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 22, 2022

@Hi @Kshitij Katiyar 

 

How did you generate or what generate payload that you paste?

 

In Confluence REST Api docs there is nothing how to get space details based on spaceId - https://docs.atlassian.com/atlassian-confluence/REST/6.6.0

 

Regards,

Seba

Kshitij Katiyar April 22, 2022

I have created a webhook using this doc 

https://docs.atlassian.com/ConfluenceServer/rest/7.2.0/#api/webhooks-createWebhook 

This webhook is delivering this payload at the url i have given in the body while making the webhook and subscribed to space related events .

You can see the this kind of payload under this heading in the below doc 

Event payloads

https://confluence.atlassian.com/confeap/managing-webhooks-1044798195.html 

Now i need to get the other information about the space but all the apis in this doc 

https://docs.atlassian.com/ConfluenceServer/rest/7.2.0/  require spaceKey rather than spaceid .I required some kind of Api to get the space key from space id because i am only getting the space id here rather than space key. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events