Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Invite to edit draft page using rest API

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

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
Community showcase
Published in Apps & Integrations

Partner Webinar Opportunities: January 2022

Hi everyone 👋, I really like the format of the webinar opportunities summary that @Jimmy Seddon posts monthly on the Welcome Centre group. It's a great place to go to check that you didn...

139 views 3 11
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you