Assignee for issue not set on creation

179 views Asked by At

I create a issue on GitLab like this(Python 3):

    user_id = int(11)
    
    gl_issue = requests.post(
        GITLAB_URL + '/api/v4/projects/%s/issues' % GITLAB_PROJECT_ID,
        headers={'PRIVATE-TOKEN': GITLAB_TOKEN,'SUDO': GITLAB_USER_NAMES.get(reporter, reporter)},
        verify=VERIFY_SSL_CERTIFICATE,
        data={
            'title': issue['fields']['summary'],
            'description': issue['fields']['description'],
            'created_at': issue['fields']['created'],
            'assignee_ids' : [user_id],
        })

Issue created but the assignee is not set. What am I doing wrong?

1

There are 1 answers

0
Alexander On

I used python-gitlab:

gl_issue = gl_issue.json()['iid']

project = gitlab.projects.get(GITLAB_PROJECT_ID)
issue = project.issues.get(gl_issue)
issue.assignee_id = user_id
issue.save()