I'm setting up the service hook for project on Azure DevOps by using Rest API (from here: https://docs.microsoft.com/en-us/rest/api/azure/devops/hooks/subscriptions/create?view=azure-devops-rest-5.0#security)
For the same user in that organization, I have successfully created service hook from the project settings (from https://dev.azure.com/{organization}/{repo}/_settings/serviceHooks). So it means that I have the right to create the subscription hook.
For programming, I used PAT for authorization with scope code(read, write) (vs.code_write) for the xxx organization. I have tried with the PAT with full_access but didn't work as well.
Here is the request:
POST https://dev.azure.com/xxx/_apis/hooks/subscriptions?api-version=5.0
Header: Authorization: Basic <Base64PAT>
Body: {
"publisherId": "tfs",
"eventType": "git.pullrequest.updated",
"resourceVersion": "1.0",
"consumerId": "webHooks",
"consumerActionId": "httpRequest",
"publisherInputs": {
"notificationType": "PushNotification",
"repository": "<repo_id>"
},
"consumerInputs": {
"url": "https://my/receiver/url/"
}
}
Here is the ERROR response:
{
"$id": "1",
"innerException": null,
"message": "The user '<user_id>\\<email>' does not have permission to edit a subscription.",
"typeName": "System.ArgumentException, mscorlib",
"typeKey": "ArgumentException",
"errorCode": 0,
"eventId": 0
}