Skip to content

Set miletone to an issue #612

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

Closed
yann-l opened this issue Oct 13, 2018 · 2 comments
Closed

Set miletone to an issue #612

yann-l opened this issue Oct 13, 2018 · 2 comments

Comments

@yann-l
Copy link

yann-l commented Oct 13, 2018

I'm not able to set the milestone to an issue:

>>> import gitlab
>>> gitlab.__version__
'1.3.0'
>>> gl = gitlab.Gitlab('https://dev.domain.tld', 'xxx')
>>> p = gl.projects.get(30)
>>> i = p.issues.get(9364)
>>> i.save()
>>> i.milestone = 1812
>>> i.save()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/gitlab/mixins.py", line 312, in save
    server_data = self.manager.update(obj_id, updated_data, **kwargs)
  File "/usr/lib/python2.7/dist-packages/gitlab/exceptions.py", line 253, in wrapped_f
    raise error(e.error_message, e.response_code, e.response_body)
gitlab.exceptions.GitlabUpdateError: 400: {"error":"title, description, assignee_ids, assignee_id, milestone_id, discussion_locked, labels, created_at, due_date, confidential, state_event are missing, at least one parameter must be provided"}

1812 is the milestone iid.
I also tried with:

>>> m = p.milestones.get(1812)
>>> m
<ProjectMilestone id:1812>
>>> i.milestone = m
>>> i.save()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/gitlab/mixins.py", line 312, in save
    server_data = self.manager.update(obj_id, updated_data, **kwargs)
  File "/usr/lib/python2.7/dist-packages/gitlab/exceptions.py", line 251, in wrapped_f
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/gitlab/mixins.py", line 227, in update
    return self.gitlab.http_put(path, post_data=data, **kwargs)
  File "/usr/lib/python2.7/dist-packages/gitlab/__init__.py", line 827, in http_put
    post_data=post_data, **kwargs)
  File "/usr/lib/python2.7/dist-packages/gitlab/__init__.py", line 685, in http_request
    prepped = self.session.prepare_request(req)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 407, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 305, in prepare
    self.prepare_body(data, files, json)
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 445, in prepare_body
    body = complexjson.dumps(json)
  File "/usr/lib/python2.7/json/__init__.py", line 244, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <ProjectMilestone id:1812> is not JSON serializable
  • python-gitlab version: 1.3.0
  • API version you are using (v3/v4): V4
  • Gitlab server version (or gitlab.com): 11.3.4
@gpocentek
Copy link
Contributor

gpocentek commented Oct 14, 2018

Hello @yann-l

You need to use the milestone_id attribute to set the milestone:

i.milestone_id = 1812
i.save()

API reference: https://docs.gitlab.com/ce/api/issues.html#edit-issue

@yann-l
Copy link
Author

yann-l commented Oct 14, 2018

indeed, that works. Thanks!

@yann-l yann-l closed this as completed Oct 14, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants