Webhook issue with JSON

Juan Pablo Cabrera July 22, 2024

Hi there!

I need all the help the community can give me with this issue. 
I have an automation rule which works with a Webhook as a trigger. After that is triggered, it has to create an issue.
I'm connecting Whatsapp with GPT, sending those reponses to a FLASK server and from then I'm creating a issue with the information.

The problem that I'm having is that when I finish the conversation from the chatbot and send the information to the FLASK server and from then to the JSM, I'm getting this error on the audit log of the automation rule:

Captura de pantalla 2024-07-22 a la(s) 9.58.29 p.m..png

 

I believe this is because there is something wrong with my JSON:



 headers = {

'Content-Type': 'application/json',

'Authorization': f'Bearer {jira_auth_token}' # Use Bearer token for authorization

}

payload = {

"fields": {

"summary": f"New candidate: {data['name']}",

"description": f"Name: {data['name']}\nEmail: {data['email']}\nPhone: {data['phone']}\nExperience: {data['experience']}",

"issuetype": {

"name": "Task"

},

"project": {

"key": "FT" # Replace with your actual project key

}

}

}
I don't know if how I'm sending the information in the JSON is correct. I also want to share how I'm managing the Webhook in case someone has the same problem:



@app.route("/webhook", methods=['POST'])

def webhook():

incoming_msg = request.form.get('Body')

client_number = request.form.get('From')

user_id = client_number

ai_response = process_message(user_id, incoming_msg)

response = MessagingResponse()

response.message(ai_response)

return str(response)

@app.route("/")

def index():

return "Hello, this is the Flask application running!"

In case you need more information in order to help me please fill free to ask.
Thanks for all the help in advance!


2 answers

1 accepted

2 votes
Answer accepted
Juan Pablo Cabrera July 23, 2024

I was making the mistake of thinking I needed an automation rule for creating an issue. But that was really not necessary, I just had to use the API Res URL from my project and give the JSON the correct format.

In case you have any doubts this is how I did it:

def create_jira_issue(data):

auth = HTTPBasicAuth(jira_email, jira_auth_token)

headers = {

'Content-Type': 'application/json',

'Accept': 'application/json'

}

payload = {

"fields": {

"summary": f"New candidate: {data['name']}",

"description": f"Name: {data['name']}\nEmail: {data['email']}\nPhone: {data['phone']}\nExperience: {data['experience']}",

"issuetype": {

"name": "Tarea"

},

"project": {

"key": "FT"

}

}

}
0 votes
Adolfo Casari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 23, 2024

@Juan Pablo CabreraCan you share your webhook configuration? I guess you need to use the option "No issues from the webhook", because you want to create a new issue instead of updating an existing one.

Juan Pablo Cabrera July 23, 2024

Hi Adolfo. What you are saying is true. I actually already solved this problem. As you mentioned, with the automation rule, I was trying to edit an existing rule rather than creating one. So when I realized that, I made the necessary changes pointing my FLASK server now to the project URL and not the WebHook URL.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events