Syntax error creating Confluence task when creating a new page using wiki/rest/api/content api

Tom VandenBerge January 30, 2018

Using postman to call the wiki/rest/api/content api to create a new page with the body (with Content-Type: application/json) below, I receive this message:

"message": "java.lang.RuntimeException: com.atlassian.confluence.content.render.xhtml.XhtmlException: com.atlassian.confluence.content.render.xhtml.XhtmlException: Missing required attribute: {http://atlassian.com/resource/identifier}username"

even though it matches the example in the "Create a page with a task" section of https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/

After searching the api doc as well as google, I can't figure out why it doesn't work. Obviously, abc@example.com is just the example. In the real post, it was a known valid user email address/login.

Body in POST

{
"type" : "page",
"status" : "current",
"title" : "TEST1: Page created through postman",
"space" : { "key" : "EIE" },
"ancestors": [{
"id": 281611148
}],
"body" : {
"storage" : {
"representation" : "storage",
"value": "<ac:task-list>\n<ac:task>\n<ac:task-status>incomplete</ac:task-status>\n<ac:task-body>\n<ac:link><ri:user ri.username='abc@example.com' /></ac:link>\nTest action created for Tom\n</ac:task-body>\n</ac:task>\n</ac:task-list>"
}
}
}

1 answer

0 votes
Tom VandenBerge February 3, 2018

Ignore - figured it out

Dirk Jacobus de Klerk April 9, 2019

Hi @Tom VandenBerge 

Could you perhaps share how you managed to sort out the issue?

I am stuck with the same error message?

Cheers

Tom VandenBerge April 9, 2019

Dirk,

I should have posted what I figured out but the solution was completely unexpected and pretty annoying. In summary, the "Create a page with a task" section of https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/ has to be taken literally including newlines and spaces. That was completely unexpected but apparently the parser would get confused without them.

The Javascript format string for each task would be:

'\\n <ac:task>\\n <ac:task-status>incomplete</ac:task-status>\\n<ac:task-body> <ac:link><ri:user ri:username=\'%s\' /></ac:link> %s </ac:task-body>\\n </ac:task>'

where %s is the user ID and task text respectively.

Wrap those lines with "<ac:task-list>" and "</ac:task-list>" and it should work for you.

Hope this helps.

Dirk Jacobus de Klerk April 9, 2019

Hi @Tom VandenBerge 

Thank you for getting back to me so quickly.

Unfortunately, my problem lies with the <ri:user> part of that string. Since they are deprecating username and userId in the new cloud migrations I no longer have access to those (have to use accountId but there is no support for that yet.)

I got the same error so thought you might have had the same issue.

Thanks for the reply anyway!

Tom VandenBerge April 10, 2019

Oh yes, I remember that I read the username was being deprecated. We're not using that particular application anymore so that fact is not an issue for me right now. I do hope they provide you a solution.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events