Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using content ids for pages created by the REST API

Jörg Wendel January 23, 2022

I'm using the REST API to create Wiki pages like this:
{"title": "ldmin", "type": "page", "space": {"key": "dh"}, "ancestors": [{"id": 602832998}], "body": {"storage": {"representation": "storage", "value": "<ri:content-entity ri:
content-id=\"cleanupAt\"><h1>CleanupAt</h1> ......

Later on I like to retrieve this page by the API to edit some parts, therefore I like to identify the part using the ri:content-id. But the ID wasn't stored. On requesting the page I only get the <ri:content-entity> element but without the content-id attribute.
What I'm doing wrong?

Thx and best regards, Jörg

2 answers

0 votes
Jörg Wendel February 9, 2022

no one an idea what goes wrong?

0 votes
Pramodh M
Community Champion
January 23, 2022

Hi @Jörg Wendel 

Welcome to Confluence!!

If your are successful with creating pages for getting content ID

Try with this API and let me know if it works

curl -u admin:passwword -X GET "http://your-conf-site.com/rest/api/content?title=A1&spaceKey=MS"

A1 is the Page title

MS is the Space Key

Thanks,
Pramodh

Jörg Wendel January 23, 2022

Thanks for the answer. Sorry I explained this a little badly.
I have no problem with creating a page with POST, nor with retrieving this or another with GET.

My problem is that I would like to give an id to the elements on the page to identify them later on. Am I going the wrong way with ri:content-id?

Jörg Wendel January 25, 2022

Here a complete example, I create a page wit POST and this payload:

{ 
  "body" : {
     "storage" : {
        "representation" : "storage",
        "value" : "<ri:content-entity ri:content-id=\"teflosPath\"><h1>TeflosPath</h1></ri:content-entity><p style=\"font-size:smaller;\">Name: teflosPath<br/>Type: string<br/>Default: <br/>Mandatory: yes<br/></p>"
     }
  },
  "ancestors" : [
     {
        "id" : 602832998
     }
  ],
  "type" : "page",
  "title" : "teflosin",
  "space" : {
     "key" : "dh"
  }
}

This works so far and the page appears in the wiki.
Now I request the page with GET and the response is:

{ 
  "_links" : {
     "base" : "https://wiki.id1.de",
     "context" : "",
     "self" : "https://wiki.id1.de/rest/api/content?spaceKey=dh&expand=body.view&type=page&title=teflosin"
  },
  "limit" : 25,
  "size" : 1,
  "start" : 0,
  "results" : [
     {
        "_expandable" : {
           "history" : "/rest/api/content/602833496/history",
           "descendants" : "/rest/api/content/602833496/descendant",
           "version" : "",
           "ancestors" : "",
           "children" : "/rest/api/content/602833496/child",
           "container" : "/rest/api/space/dh",
           "space" : "/rest/api/space/dh",
           "operations" : "",
           "metadata" : "",
           "restrictions" : "/rest/api/content/602833496/restriction/byOperation"
        },
        "_links" : {
           "self" : "https://wiki.id1.de/rest/api/content/602833496",
           "tinyui" : "/x/WILuIw",
           "webui" : "/display/dh/teflosin",
           "edit" : "/pages/resumedraft.action?draftId=602833496"
        },
        "status" : "current",
        "body" : {
           "_expandable" : {
              "editor" : "",
              "anonymous_export_view" : "",
              "storage" : "",
              "styled_view" : "",
              "export_view" : ""
           },
           "view" : {
              "representation" : "storage",
              "_expandable" : {
                 "content" : "/rest/api/content/602833496",
                 "webresource" : ""
              },
              "value" : "<ri:content-entity><h1 id=\"teflosin-TeflosPath\">TeflosPath</h1></ri:content-entity><p style=\"font-size: smaller;\">Name: teflosPath<br/>Type: string<br/>Default: <br/>Mandatory: yes<br/></p>"
           }
        },
        "extensions" : {
           "position" : "none"
        },
        "id" : "602833496",
        "type" : "page",
        "title" : "teflosin"
     }
  ]
}





This is also working with the exception that ri:content-id is missing.

Any idea what is going wrong?

Thanks
Jörg

Like Nico Beckers likes this
Nico Beckers
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!
May 9, 2025

I am having the exact same problem. Even though the documentation states that ri:content-id is a required attribute, it seems to get stripped by confluence upon page creation. Is there any other way to add some identifier to elements, such that I can find them later on (and that survive page edits)?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events