Browse Source
Merge pull request #2244 from mslourens/headers_in_webhook_automation_step
add headers input in outgoing webhook automation step
gh-pages
Martin McKeaveney
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
16 additions and
1 deletions
-
packages/server/src/automations/steps/outgoingWebhook.js
|
|
|
@ -27,6 +27,7 @@ module.exports.definition = { |
|
|
|
requestMethod: "POST", |
|
|
|
url: "http://", |
|
|
|
requestBody: "{}", |
|
|
|
headers: "{}", |
|
|
|
}, |
|
|
|
schema: { |
|
|
|
inputs: { |
|
|
|
@ -45,6 +46,11 @@ module.exports.definition = { |
|
|
|
title: "JSON Body", |
|
|
|
customType: "wide", |
|
|
|
}, |
|
|
|
headers: { |
|
|
|
type: "string", |
|
|
|
title: "Headers", |
|
|
|
customType: "wide", |
|
|
|
}, |
|
|
|
}, |
|
|
|
required: ["requestMethod", "url"], |
|
|
|
}, |
|
|
|
@ -65,7 +71,7 @@ module.exports.definition = { |
|
|
|
} |
|
|
|
|
|
|
|
module.exports.run = async function ({ inputs }) { |
|
|
|
let { requestMethod, url, requestBody } = inputs |
|
|
|
let { requestMethod, url, requestBody, headers } = inputs |
|
|
|
if (!url.startsWith("http")) { |
|
|
|
url = `http://${url}` |
|
|
|
} |
|
|
|
@ -84,6 +90,15 @@ module.exports.run = async function ({ inputs }) { |
|
|
|
request.headers = { |
|
|
|
"Content-Type": "application/json", |
|
|
|
} |
|
|
|
|
|
|
|
if (headers && headers.length !== 0) { |
|
|
|
try { |
|
|
|
const customHeaders = JSON.parse(headers) |
|
|
|
request.headers = { ...request.headers, ...customHeaders } |
|
|
|
} catch (err) { |
|
|
|
console.error(err) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
|