Skip to main content

Hi - unless I’ve missed it - is there a way to add webhooks to commvault via the API?

Hey @Mike Gale , thanks for the post!

Is this what you’re looking for?

https://documentation.commvault.com/2022e/essential/144668_adding_webhook.html

If not, let me know your end goal and I’ll get a better link 🤓


I think @Mike Gale is looking for the payload that allows you to create the webhook from code. Checked api.commvault.com quickly but can't find it myself so I think someone should send a request to the team if they can documented it on the API documentation. 

You could try, in the meantime, to capture the body once you submit the creation via the browser. 


Hi 

Thanks for the replies - yes I’m looking at writing a python script that along with other things - automatically adds MS Teams Webhooks. I’ve been able to figure out most steps - just webhooks don’t seem to be an option and I still have to manually add them in the webconsole.

Mike


I’ll see what I can gather.

Adding @clecky as the man seems to know PowerShell like no one else.


I got a reply, right from dev:

POST {{ServerURL}}/Webhook

Body:

<Api_CreateWebhook headers="Authorization=Splunk 1be3a69e-c5e8-407c-b6bf-1adce9719a19" name="splunktestwh-del2" secret="hamactext" ssl="1" url="<WEBHOOK_URL>" />

Let me know if that helps!


I’ll see what I can gather.

Adding @clecky as the man seems to know PowerShell like no one else.

I’m a little late to the party as it looks like you have provided the solution for the payload.

At the very least maybe I can help by sharing the instructions from Microsoft for the teams web hook

 

https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL

 

Originally provided by @Mrityunjay Upadhyay 

In this post.


Hi

Thanks for the responses.


I’m using the python requests library:

Capturing the payload using chrome dev tools gives this:

{
"name":"mikes_testing",
"url":"test-webhook.com",
"ssl":false
}

But if I provide the above json payload I get:  Request body is empty or format is invalid.

I have many working Post requests and as this is the “captured” payload I’m a bit stumped. 

 

 


Can you show the post command you are using?


## READ POST DATA JSON
with open('Payload/create_webhook.json') as json_file:
json_data = json_file.read()

## CREATE HEADERS
headers = {'Cookie2': token, "Accept": "application/json", "Content-Type": "application/json"}

## GENERATE REQUEST
r = requests.post(clientPropsReq, json=json_data, headers=headers)
resp = r.text
print(resp)
print(r.status_code)


This works for all other post requests I’ve been testing (just not webhooks) - but that’s fine if its not supported yet :)
 


I don’t know much about Python, so I’ll have to do some reading to get details but my guess is that. 

json=json_data

Is where your issue is as the payload you posted looks incomplete, referencing what @Mike Struening posted you are missing some elements Mike posted in XML but at the very least it looks it looks like you are missing “Authorization” and “Secret” which implies that the Json file is incomplete.

At some point I am going to try using this in my own workflows so I’ll putz around with this and see if I can be more helpful.

 

 

 


Reply