Webhook issue with JSON
Asked by Juan Pablo Cabrera:

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](/t5/image/serverpage/image-id/337178i982A46B757E01A0E/image-size/large?v=v2&px=999 "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:  

<br />

<br />

```
 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:  

<br />

<br />

```
@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!  

<br />


Answers:
author: Juan Pablo Cabrera
body: 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"

 }

 }

 }
```


author: Adolfo Casari
body: [@Juan Pablo Cabrera](/t5/user/viewprofilepage/user-id/5537956)Can 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.

comments: author: Juan Pablo Cabrera
body: 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.


Tags: cloud

jira-service-management

jira-service-management-cloud

json

server

webhook