Problem when using a Generic Webhook

(qinhao) #1

Hi there

According to Webhooks — StackStorm 2.8.1 documentation generic webhook part.
I define a rule like below

name: “postmsg_chatterbot”
pack: “chatterbot”
enabled: true
description: “Rule to send message to chatterbot”
type: “chartterbot.postmsg”
pattern: “workflow”
type: “equals”
ref: chatterbot.postmsg_chatterbot
dstuser: “{{trigger.dstuser}}”
dstgroup: “{{trigger.dstgroup}}”
message: “{{trigger.message}}”
url: “{{trigger.url}}”

Use postman to post a request to ST2, no response.

look into the st2api.log , found the error trigger not specified
log details as follow:

2018-08-29 01:14:49,141 140379119891152 INFO logging [-] 1e588f8c-bbaf-47ba-a8c7-6b7556cc260b - GET /v1/webhooks with query={} (remote_addr=‘’,method=‘GET’,request_id=‘1e588f8c-bbaf-47ba-a8c7-6b7556cc260b’,query={},path=’/v1/webhooks’)
2018-08-29 01:14:49,145 140379119891152 AUDIT auth [-] Token with id “5b852bb710dbbe01782e3744” is validated.
2018-08-29 01:14:49,148 140379119891152 INFO logging [-] 1e588f8c-bbaf-47ba-a8c7-6b7556cc260b - 200 396 6.34ms (content_length=396,request_id=‘1e588f8c-bbaf-47ba-a8c7-6b7556cc260b’,runtime=6.34,remote_addr=‘’,status=200,method=‘GET’,path=’/v1/webhooks’)
2018-08-29 01:34:47,121 140379119891152 INFO logging [-] e3be293c-ebf0-431f-9141-590a41051337 - POST /v1/webhooks/st2 with query={} (remote_addr=‘’,method=‘POST’,request_id=‘e3be293c-ebf0-431f-9141-590a41051337’,query={},path=’/v1/webhooks/st2’)
2018-08-29 01:34:47,124 140379119891152 AUDIT auth [-] API key with id “5b85efd610dbbe01a9c5f212” is validated.
2018-08-29 01:34:47,128 140379119891152 ERROR router [-] Failed to call controller function “post” for operation “”: Trigger not specified.
Traceback (most recent call last):
File “/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/”, line 477, in call
resp = func(**kw)
File “/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2api/controllers/v1/”, line 143, in post
return abort(http_client.BAD_REQUEST, msg)
File “/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/”, line 55, in abort
raise exc.status_mapstatus_code
HTTPBadRequest: Trigger not specified.
2018-08-29 01:34:47,129 140379119891152 INFO logging [-] e3be293c-ebf0-431f-9141-590a41051337 - 400 47 8.531ms (content_length=47,request_id=‘e3be293c-ebf0-431f-9141-590a41051337’,runtime=8.531,remote_addr=‘’,status=400,method=‘POST’,path=’/v1/webhooks/st2’)

postman param like below

what’s the problem with my steps, what’s do i miss?

(Lindsay Hill) #2

Could you please use the formatting options for that YAML? Use either ``` before & after the code block, or use the formatting buttons.

That way we can check the indentation in your YAML file, to make sure it is correct.

(Lindsay Hill) #3

Also, try using curl like in the documentation, rather than Postman. It’s a bit hard to check a screenshot to see if you have all of your Postman settings correct.

Or use Postman to generate the equivalent curl call, and post it here so we can see what you’re actually sending

(qinhao) #5

name:"postmsg_chatterbot" pack:“chatterbot”
enabled:true description:“Ruletosendmessagetochatterbot" trigger: ``type:"chartterbot.postmsg”
trigger.source: ````pattern:`"workflow" ````type:`"equals" action:ref:chatterbot.postmsg_chatterbot ``parameters: ````dstuser:"{{trigger.dstuser}}"
dstgroup:`"{{trigger.dstgroup}}"message:"{{trigger.message}}" ````url:"{{trigger.url}}"

Is this the yaml format you need

(qinhao) #6

curl --request POST
–header ‘Cache-Control: no-cache’
–header ‘Content-Type: application/x-www-form-urlencoded’
–header ‘Postman-Token: e1612969-f846-4c0e-aafd-62217578fa19’
–header ‘St2-Api-Key: ZjRmY2Y0Mzk1YzExYWM3Mjk0NmRlMWIyYmQyYjI4OTc4ODQ0MDdiMjgxYTBhNjY1NzBiMWNkNWNlOGMyZmNmNw’
–header ‘content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW’
–form trigger=chartterbot.postmsg
–form ‘payload=“source”: “workflow”,“dstuser”:“q00w”,“dstgroup”:"",“message”:“abcdefghijklmn”,“url”:“”’

postman code

(Lindsay Hill) #7

No - that’s almost impossible to read. Put ``` at the start and the end of all fixed-width blocks. Same Markdown style as Github.

Or use the “Preformatted text” button at the top of this text entry box. image

(Lindsay Hill) #8

Note: You can also go back and edit an existing post to format the text.

This is what YAML should look like when you use proper formatting:

name: "send_sms"
runner_type: "python-script"
description: "This sends an SMS using twilio."
enabled: true
entry_point: ""
        type: "string"
        description: "Your twilio 'from' number in E.164 format. Example +14151234567."
        required: true
        position: 0
        type: "string"
        description: "Recipient number in E.164 format. Example +14151234567."
        required: true
        position: 1
        secret: true
        type: "string"
        description: "Body of the message."
        required: true
        position: 2
        default: "Hello {% if system.user %} {{ st2kv.system.user }} {% else %} dude {% endif %}!"

See how much easier that is to read than a big blob of text? It also makes it easy to check the indentation

(Lindsay Hill) #9

That doesn’t look right.

Look at the example given in the documentation:

curl -X POST https://localhost/api/v1/webhooks/st2 -H "X-Auth-Token: matoken" -H "Content-Type: application/json" --data '{"trigger": "mypack.mytrigger", "payload": {"attribute1": "value1"}}'

See how the JSON body is passed as --data, not a form.

I don’t use Postman, so can’t tell you the best way to use that. For now you could just use curl

(qinhao) #10

thanks a lot. probleam sovled~