Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,505,777
Community Members
 
Community Events
180
Community Groups

How do we add an in-line comment to Confluence content using the REST API?

Hello!

I am trying to add an in-line comment using the REST API.  Google pointed me to the following request format, however this fails with an error (see response).

Also, I am guessing at what to put in serializedHighlights, (it is flagged in the error response if not present in the request) so if anyone knows anything about that, I'll be pleased to receive advice on that!

I haven't looked at the code yet.

 

Here's the outgoing request:

POST {{server}}/rest/api/content
 
{
    "type": "comment",
    "mode": "create",
    "container": 
      {
        "id": "2031625",
        "type": "page"        
    },
    "body": {
        "storage": {
            "value": "<p>This inline comment added from REST API</p>",
            "representation": "storage"
        }
    },
    "extensions": {       
        "location": "inline",
        "inlineProperties": {
            "numMatches": 1,
            "originalSelection": "Hello From me",
            "matchIndex": 0,
          "serializedHighlights" : "[[\"Hello From me\"]]"
        }
    }
}

 

And the error response:

{
    "statusCode": 400,
    "data": {
        "authorized": true,
        "valid": false,
        "errors": [
            {
                "message": {
                    "key": "lastFetchTime",
                    "args": []
                }
            }
        ],
        "successful": false
    },
    "message": "Could not create content with type comment"
}

 

Regards,

Chris

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Jaime S Atlassian Team Feb 21, 2017

Hi, Chris.

So, I was having the same issue and then I realized it was complaining about the a missing 'lastFetchTime' attribute. I'm not sure what it is exactly, it seems to be the date where it was last fetched. After some tests, I found out it is a date represented as a timestamp (so, a long integer).

I generated one using http://www.epochconverter.com/.

This worked for me:

 

...
    "extensions": {      
        "location": "inline",
        "inlineProperties": {
            "numMatches": 1,
            "originalSelection": "Hello From me",
            "matchIndex": 0,
            "serializedHighlights" : "[[\"Hello From me\"]]",
            "lastFetchTime":"1487711412"
...

I hope this helps.

Kind regards,
Jaime Kirch da Silveira
Atlassian Cloud Support

TAGS
AUG Leaders

Atlassian Community Events