trianglesis
trianglesis

Reputation: 83

How to POST via REST a correct markup to a confluence page?

How to post topic in correct wiki syntax when body has "\r\n" which means "carriage return" and "newline"?

When I use data=json.dumps(%topic_body%) it makes all my text with literally "\r\n" in it!

Of course text formatted like this - cannot be used as wiki formatted on confluence!

This is an example of usual markup:

h1. Some Description
[Some link|Link...] is ...

h2. Some

h2. Some Versions
* 9
*  10
*  11

h1. Some Software 

||Table 1 ||Block 1||Some||Some 2||

This is how it reproduces via json:

{"storage": {"value": "b'h1. Some Description\\r\\n[Some link|Link...] is ...\\r\\n\\r\\nh2. Some\\r\\n\\r\\nh2. Some Versions\\r\\n* 9\\r\\n*  10\\r\\n*  11\\r\\n\\r\\nh1. Some Software \\r\\n\\r\\n||Table 1 ||Block 1||Some||Some 2||'", "representation": "wiki"}}}

This is important, and I can't send body in markdown because my confluence did not understand this way of macros:

<ac:structured-macro ac:name="attachments">
</ac:structured-macro>

So I need to send my topic body that way, which can include new line method (https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html)

Also I can't use documented:

Explicitly, by entering two consecutive backslashes: \\

Because in this condition wiki markup make all text the same forematted, just like:

h1. Some Description \\ \\ [Some link|Link...] is ...

This whole string will be "h1." size. All all other text from this string will be formatted as h1, ignoring any other tags.

Upvotes: 1

Views: 2997

Answers (2)

Ievgenii Vasiuk
Ievgenii Vasiuk

Reputation: 1

So, how the line breaks worked for you? Using this still gives me whole string "h1." size.:

{"value": "b'h1. Some Description\\r\\n[Some link|Link...] is ...\\r\\n'"}

Upvotes: 0

trianglesis
trianglesis

Reputation: 83

Fixed! You can ignore the case, when visual(in browser) wiki markdown does not work for you. It will work via REST anyway!

Upvotes: 1

Related Questions