Get TFS Webhook SubscriptionStatus

时光怂恿深爱的人放手 提交于 2020-01-06 02:46:10

问题


From my previous question link here it appears that we do not have a feature in any version of TFS/Azure DevOps to setup monitoring for the webhook subscriptions.

As a workaround I'm now looking to write a PowerShell script to check the heartbeat of the subscription. From the Microsoft documentation link here it appears we can get the SubscriptionStatus by querying the subscription ID.

On a GET request for below API I receive all the details specified in the documentation but I'm unable to find "status" in the response. Does anybody know if there is any other way to get the SubscriptionStatus.

https://collectionurl/_apis/hooks/subscriptions/3d9af4ba-d642-4c80-8d62-34cabca322f9


回答1:


Try listing the subscriptions instead:

GET https://collectionurl/_apis/hooks/subscriptions?api-version=5.1

You can filter the results using query parameters as follows:

GET https://collectionurl/_apis/hooks/subscriptions?publisherId={publisherId}&eventType={eventType}&consumerId={consumerId}&consumerActionId={consumerActionId}&api-version=5.1

You should see status there somewhere.




回答2:


I found that my API in question is correct, but for some reason i'm not getting 'enabled' status, I tested successfully for all other status mentioned here.

I'm now setting up my PowerShell to execute every 5mins to check the webhook for its status and send an email for any other status than 'enabled'.

If the status is 'enabled' or 'empty' I further check consumerInputs.url to check if the webhook is alive.

This works perfectly fine.



来源:https://stackoverflow.com/questions/58492467/get-tfs-webhook-subscriptionstatus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!