Browse Source

add headers input in outgoing webhook automation step

gh-pages
Maurits Lourens 5 years ago
parent
commit
c8a4fc55ce
  1. 12
      packages/server/src/automations/steps/outgoingWebhook.js

12
packages/server/src/automations/steps/outgoingWebhook.js

@ -27,6 +27,7 @@ module.exports.definition = {
requestMethod: "POST", requestMethod: "POST",
url: "http://", url: "http://",
requestBody: "{}", requestBody: "{}",
headers: "{}",
}, },
schema: { schema: {
inputs: { inputs: {
@ -45,6 +46,11 @@ module.exports.definition = {
title: "JSON Body", title: "JSON Body",
customType: "wide", customType: "wide",
}, },
headers: {
type: "string",
title: "Headers",
customType: "wide",
},
}, },
required: ["requestMethod", "url"], required: ["requestMethod", "url"],
}, },
@ -65,7 +71,7 @@ module.exports.definition = {
} }
module.exports.run = async function ({ inputs }) { module.exports.run = async function ({ inputs }) {
let { requestMethod, url, requestBody } = inputs let { requestMethod, url, requestBody, headers } = inputs
if (!url.startsWith("http")) { if (!url.startsWith("http")) {
url = `http://${url}` url = `http://${url}`
} }
@ -84,6 +90,10 @@ module.exports.run = async function ({ inputs }) {
request.headers = { request.headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
} }
if (headers && headers.length !== 0) {
request.headers = { ...request.headers, ...JSON.parse(headers) }
}
} }
try { try {

Loading…
Cancel
Save