Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_temp_project_avatar() fails with Jira Cloud #1935

Open
2 of 4 tasks
gpflaum opened this issue Jan 15, 2025 · 0 comments
Open
2 of 4 tasks

create_temp_project_avatar() fails with Jira Cloud #1935

gpflaum opened this issue Jan 15, 2025 · 0 comments

Comments

@gpflaum
Copy link

gpflaum commented Jan 15, 2025

Bug summary

create_temp_project_avatar() works with Jira Data Center, but fails with Jira Cloud with a 405 (Method Not Allowed) error:

jira.exceptions.JIRAError: JiraError HTTP 405 url: https://mysite.atlassian.net/rest/api/2/project/MYPROJECT/avatar/temporary?filename=avatar.png&size=4950

The Jira Cloud REST API doesn't have separate APIs for loading a temp avatar and cropping it. It has just one "Load project avatar" API: /project/{projectIdOrKey}/avatar2 (API v2 and API v3)

I haven't tested, but

Is there an existing issue for this?

  • I have searched the existing issues

Jira Instance type

Jira Cloud (Hosted by Atlassian)

Jira instance version

Cloud

jira-python version

3.9

Python Interpreter version

3.12

Which operating systems have you used?

  • Linux
  • macOS
  • Windows

Reproduction steps

props = jira.create_temp_project_avatar(
                    project="MYPROJECT",
                    filename="avatar.png",
                    size=avatar_path.stat().st_size,
                    contentType="image/png",
                    avatar_img=avatar_file.read(),
                    auto_confirm=True,
                )

Stack trace

File "/Users/gpflaum/ws/jira-tools/set_project_custom_avatar.py", line 78, in set_project_avatars
    props = jira.create_temp_project_avatar(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gpflaum/ws/venv/lib/python3.11/site-packages/jira/client.py", line 203, in wrapper
    result = func(*arg_list, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gpflaum/ws/venv/lib/python3.11/site-packages/jira/client.py", line 3301, in create_temp_project_avatar
    r = self._session.post(url, params=params, headers=headers, data=avatar_img)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gpflaum/ws/venv/lib/python3.11/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gpflaum/ws/venv/lib/python3.11/site-packages/jira/resilientsession.py", line 247, in request
    elif raise_on_error(response, **processed_kwargs):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gpflaum/ws/venv/lib/python3.11/site-packages/jira/resilientsession.py", line 72, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 405 url: https://mysite.atlassian.net/rest/api/2/project/MYPROJECT/avatar/temporary?filename=avatar.png&size=4950


### Expected behaviour

Expected avatar to be created in project.

### Additional Context

_No response_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant