Skip to content

Cannot update Slack Integration's webhook #1188

Closed
@iTaybb

Description

@iTaybb

Description of the problem, including code/CLI snippet

Changing a a slack service integration wehbook is not possible through slacksvc.properties['webhook'], and slacksvc.webhook is not available.

gl = gitlab.Gitlab('https://gitlab.******', private_token=os.environ['GITLAB_API_TOKEN'])
svc = gl.projects.get('test').services.get('slack')

slacksvc.properties['webhook'] = 'https://**************'
slacksvc.save()

Expected Behavior

Success

Actual Behavior

send: b'PUT /api/v4/projects/33/services/slack HTTP/1.1\r\nHost: gitlab.****************\r\nUser-Agent: python-gitlab/2.5.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: P**************f\r\nContent-type: application/json\r\nContent-Length: 32\r\n\r\n'
send: b'{"id": "slack"}'
reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Server: nginx
header: Date: Sun, 13 Sep 2020 13:02:56 GMT
header: Content-Type: application/json
header: Content-Length: 30
header: Connection: keep-alive
header: Cache-Control: no-cache
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Request-Id: **********
header: X-Runtime: 0.017246
DEBUG:urllib3.connectionpool:http://gitlab.**************:80 "PUT /api/v4/projects/33/services/slack HTTP/1.1" 400 30
*** gitlab.exceptions.GitlabUpdateError: 400: webhook is missing

Workaround

Direct PUT request seems to be working fine:

 gl = gitlab.Gitlab('https://gitlab.******', private_token=os.environ['GITLAB_API_TOKEN'])
 data = {'webhook': 'http://***************'}
 gl.http_put('/projects/{0}/services/slack'.format(gl.projects.get('test').id), post_data=data)

Specifications

  • python-gitlab version: 2.5.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 13.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions