atlassian-python-api icon indicating copy to clipboard operation
atlassian-python-api copied to clipboard

Update the error message for update_page function

Open aujjwal-smarsh opened this issue 4 years ago • 1 comments

Hi all,

I have been using the API for a long time. Thanks to all the contributors for the great work. It has helped me a lot for automating content pushing and updating.

I was facing this error continuously:

No space or no content type, or setup a wrong version type set to content, or status param is not draft and status content is current

I checked into the function and found it in the page https://github.com/atlassian-api/atlassian-python-api/blob/3ee13e384c2e7f642af9aae3066b22f09321e3b6/atlassian/confluence.py

But none of the things were coming out to be correct as I could see from the error message. Everything was fine in my code and it was working for a set of data while failing for the other set. I debugged a lot before finding that because of an & in my body (html body which I was trying to push) it was failing. I removed the & and it's working great.

 <tr>
                                <td style="border: 1px solid black;">
                                Company & Co. Inc.
                                </td>
                                <td style="border: 1px solid black">
                                0
                                </td>

If anyone can modify the error message to point out this situation as well it can prevent hours of debugging.

aujjwal-smarsh avatar Aug 27 '21 11:08 aujjwal-smarsh

And for others finding there way here, you can use html.escape() to escape a string to HTML-safe: https://docs.python.org/3/library/html.html#html.escape

cacack avatar Feb 01 '22 16:02 cacack

In my case, the html was already escaped but the issue was with a control character in the data.

Doing the below solved the problem

body = re.sub(r'[\x00-\x1f\x7f-\x9f]+', '', body)

metalshanked avatar Feb 07 '23 17:02 metalshanked