opsgenie / opsgenie-go-sdk-v2

Opsgenie GO SDK v2
Apache License 2.0
35 stars 64 forks source link

Update integration fails with error - "You can not assign integration to another team" #35

Open milonjames opened 4 years ago

milonjames commented 4 years ago

Hi, I am getting the following error while trying to update an integration.

{"code":40301,"message":"You can not assign integration to another team","took":0.002,"requestId":"2986a890-3fd3-4f5e-973b-4e6034c5936a"}

I think this could be due to a bug in the function 'ForceUpdateAllFields'

https://github.com/opsgenie/opsgenie-go-sdk-v2/blob/v1.1/integration/integration.go#L57

There we can see that it's not passing the 'OwnerTeam' argument to the request. And in my trial runs using curl, I found that if I try to update an integration without passing the 'ownerTeam' argument in the JSON payload, it will result in the same error.

curl -X PUT 'https://api.eu.opsgenie.com/v2/integrations/<integration_id>' --header 'Authorization: GenieKey<API_KEY>' --header 'Content-Type: application/json' --data '{ "enabled": true, "ignoreRespondersFromPayload": true, "name": "<INTEGRATION_NAME>", "suppressNotifications": true, "responders": [], "type": "API" }'

{"code":40301,"message":"You can not assign integration to another team","took":0.002,"requestId":"2986a890-3fd3-4f5e-973b-4e6034c5936a"}

Please note I am using an API key from an API integration which I have created under my 'team' to authenticate the SDK to OpsGenie. Could that be an issue?

cemkucuk commented 4 years ago

hey @milonjames Does this problem still exist? Can you confirm?