Using content ids for pages created by the REST API
Asked by J?rg Wendel:

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  


Answers:
author: J?rg Wendel
body: no one an idea what goes wrong?


author: Pramodh M
body: Hi [@J?rg Wendel](/t5/user/viewprofilepage/user-id/4722989)

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

comments: author: J?rg Wendel
body: 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?


author: J?rg Wendel
body: 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


Tags: confluence-server

rest-api

server