简体   繁体   中英

c# web api as jira webhook url

I have been tasked to implement a JIRA SMS notification(using Twilio) similar to its in-built email notification. I know this can be easily done using Zapier and Twilio. But i am told to look for a workaround with out using Zapier. The only option i think of now is to create a WebApi project that calls Twilio to send the SMS, host the WebApi project on a server and pass this URL as a WEBHOOK in JIRA.

For this i have created a C# class library which calls Twilio.

class

and after that i have added a new WebApi project for this solution and added the above class project reference. and i have added a new controller: controller

i am just calling the send method from the constructor with out any parameters which i think will do the job just from hardcoded number to a given number(in the controller.

but what i need is to pass in messageBody and recipientPhoneNumber from the JIRA webhook to this controller. Not sure how to do this.

As i am very new to WebApi's could some one please help me with the code. much appreciated.

Twilio Dev Evangelist here...

Mind dropping me a note at corey@twilio.com? I agree with the previous responses - this site may not be the best forum to support what you're looking for here, but I would be more than happy to directly help you out here.

but what i need is to pass in messageBody and recipientPhoneNumber from the JIRA >webhook to this controller. Not sure how to do this.

The way webhooks work is a little bit different than your assumption above. You cannot pass anything to JIRA webhook. JIRA POSTs data to the webhook (your API URL). Once you receive the data in your API controller action, you can construct a message body and recipient phone number (from eg user object passed in by JIRA; if that object doesn't have any phone number attribute, you might have to use a custom field).

As i am very new to WebApi's could some one please help me with the code. much appreciated.

No problem. I guess you have done the Twilio part alright already. Please visit MS docs to know more about Web API. You have to add a controller method so that it can be called by JIRA. So your final URL becomes this . You can then put this URL in JIRA as webhook. Replace hostname by your server hostname and change other url segments based on your situation. ,并根据您的情况更改其他URL段。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM