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

[Confluence Cloud] create_or_update_template always returns a 400 JsonMappingException

Open mikewyer opened this issue 3 years ago • 5 comments

This feels like a bug in the ContentTemplate schema on the server side rather than a code bug, but it's hard to be sure.

What I do know is that trying to update an existing template via the API always fails with:

HTTPError: org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class 
com.atlassian.confluence.api.model.content.template.ContentTemplate] from JSON String; no single-String constructor/factory method

Example code: successfully fetching an existing template, then trying to "update" it without any changes:

template_data = wiki.confluence.get_content_template(template_id)
confluence.create_or_update_template(
            name=template_data["name"],
            body=template_data["body"],
#            body={"representation": "view", "value": "lorem ipsum"},
            template_id=template_id,
            description=template_data["description"],
            labels=template_data["labels"],
            space=template_data["space"]["key"],
        )

mikewyer avatar Nov 23 '22 15:11 mikewyer

@mikewyer is this on-prem Confluence or cloud one ?

gonchik avatar Nov 23 '22 15:11 gonchik

Cloud

mikewyer avatar Nov 23 '22 15:11 mikewyer

@mikewyer do you have some payload?

gonchik avatar Jan 04 '23 16:01 gonchik

Yes, right there in the example code

On Wed, 4 Jan 2023, 16:30 Gonchik Tsymzhitov, @.***> wrote:

@mikewyer https://github.com/mikewyer do you have some payload?

— Reply to this email directly, view it on GitHub https://github.com/atlassian-api/atlassian-python-api/issues/1083#issuecomment-1371150150, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEZOUATCHR4OXYWOW54JLOTWQWQSRANCNFSM6AAAAAASJCLM3I . You are receiving this because you were mentioned.Message ID: @.***>

mikewyer avatar Jan 04 '23 16:01 mikewyer

I'm happy to try other invocations with different data if that would help. But I tried to provide the most minimal, valid (according to the API docs) example that shows the problem.

I've tried with bigger payloads, downloading an existing template via the API and then playing it back exactly, and it still fails.

On Wed, 4 Jan 2023, 16:34 Mike Wyer, @.***> wrote:

Yes, right there in the example code

On Wed, 4 Jan 2023, 16:30 Gonchik Tsymzhitov, @.***> wrote:

@mikewyer https://github.com/mikewyer do you have some payload?

— Reply to this email directly, view it on GitHub https://github.com/atlassian-api/atlassian-python-api/issues/1083#issuecomment-1371150150, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEZOUATCHR4OXYWOW54JLOTWQWQSRANCNFSM6AAAAAASJCLM3I . You are receiving this because you were mentioned.Message ID: @.***>

mikewyer avatar Jan 04 '23 16:01 mikewyer