atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.34k stars 660 forks source link

[Confluence Cloud] create_or_update_template always returns a 400 JsonMappingException #1083

Open mikewyer opened 1 year ago

mikewyer commented 1 year ago

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"],
        )
gonchik commented 1 year ago

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

mikewyer commented 1 year ago

Cloud

gonchik commented 1 year ago

@mikewyer do you have some payload?

mikewyer commented 1 year ago

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 commented 1 year ago

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: @.***>