Invite to edit draft page using rest API

Oleksandr Demianchuk
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 17, 2021

Hi,

I`m creating page in confluence by using rest API.
[atlassian url]/wiki/rest/api/content.

But this page is visible only to me. I want to share it with my colleagues.

For this, I have to go in confluence and add them manually.

InvitationMenu.png

It uses this endpoint:

[atlassian url]/gateway/api/share

I didn't find how to do it by rest API. Does this endpoint exist or on the creation can be set? Or can I create a draft page for another user?

 

My request body

var requestBody = new
{
id = DateTime.Now.Ticks,
status = "draft",
type = "page",
title = title,
space = new
{
key = "key"
},
body = new
{
storage = new
{
value = body,
representation = "storage"
},
},
ancestors = new List<object>() { new { id = ancestorId } },
};

1 answer

0 votes
WW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 6, 2022

The REST API you're looking at will give you the content information, it won't actually do anything like share the page.

/rest/api/content

You could get the pageId from it, though, to use in the other REST API call below.

I'm just going to assume you're using Confluence Server or Data Center, since that's what I know, and hope the answer is similar for Cloud. :)

When I pressed F12 to see the Developer Console in my browser right before I shared a page, then I shared.  I saw it hit this REST API:

/rest/share-page/latest/share

with Json that looks something like this (I changed the data, so you'd need to insert your own):

{
"users":["sdfsdfsfdw34525dfh3563563er"]
,"emails":[]
,"groups":[]
,"note":"test"
,"entityId":"123456789"
,"entityType":"page"
,"contextualPageId":"123456789"
}

The users part was originally the user key - that big long key they're using now for user privacy instead of the username.  You'd have to grab those from somewhere or know what they are.  Or just use the emails part.

I shared and looked at the Console from View mode, Edit mode, and an unpublished draft, and it was all the same REST API.

If

[atlassian url]/gateway/api/share

is the Cloud version of what I posted, then if I were you, I'd press F12, etc. like I did, and see what was in the Request part of the call.  You may be able to see what the Json would be like there.

If not, then I hope this is helpful to someone else one day!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events