Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 从TypeScript Azure函数调用MS Power Automation_Node.js_Azure Functions_Power Automate - Fatal编程技术网

Node.js 从TypeScript Azure函数调用MS Power Automation

Node.js 从TypeScript Azure函数调用MS Power Automation,node.js,azure-functions,power-automate,Node.js,Azure Functions,Power Automate,如何从TypeScript Azure函数触发MS Power Automation HTTPtrigger。任何人我一直在尝试,但没有任何运气 const data = JSON.stringify({ todo: 'Buy the milk' }) const options = { hostname: flowUrl, method: 'POST', headers: { 'Content-Type': 'application/j

如何从TypeScript Azure函数触发MS Power Automation HTTPtrigger。任何人我一直在尝试,但没有任何运气

const data = JSON.stringify({
    todo: 'Buy the milk'
  })
  
  const options = {
    hostname: flowUrl,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Content-Length': data.length
    }
  }
  
  const req = https.request(options, res => {
    console.log(`statusCode: ${res.statusCode}`)
  
    res.on('data', d => {
      process.stdout.write(d)
    })
  })
  
  req.on('error', error => {
    console.error(error)
  })
  
  req.write(data)
  req.end()

    

似乎您只是在
选项中使用了
主机名
属性,但没有
端口
路径
属性。我们不能将整个流url放在
选项的
主机名
中,我们需要将其分离为
主机名
端口
路径

例如,我的流url是
https://prod-06.eastasia.logic.azure.com:443/workflows/e79330xxxxxxxxxxxcf029ac/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=MEAZY9XXXXXXXXXXXXXXXXXXXXPQCWJBCC2MG
,则代码应如下所示:

const options = {
    hostname: "prod-06.eastasia.logic.azure.com",   //note: do not add "https://" here
    method: 'POST',
    port: '443',
    path: '/workflows/e79330xxxxxxxxxxxcf029ac/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=mEAzy9xxxxxxxxxxxxxxxxxPqCwJBCc2mg',
    headers: {
      'Content-Type': 'application/json',
      'Content-Length': data.length
    }
}

更改后,代码可以在my power Automation中触发http触发器。

您似乎只在
选项中使用了
主机名
属性,但没有
端口和
路径属性。我们不能将整个流url放在
选项的
主机名
中,我们需要将其分离为
主机名
端口
路径

例如,我的流url是
https://prod-06.eastasia.logic.azure.com:443/workflows/e79330xxxxxxxxxxxcf029ac/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=MEAZY9XXXXXXXXXXXXXXXXXXXXPQCWJBCC2MG
,则代码应如下所示:

const options = {
    hostname: "prod-06.eastasia.logic.azure.com",   //note: do not add "https://" here
    method: 'POST',
    port: '443',
    path: '/workflows/e79330xxxxxxxxxxxcf029ac/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=mEAzy9xxxxxxxxxxxxxxxxxPqCwJBCc2mg',
    headers: {
      'Content-Type': 'application/json',
      'Content-Length': data.length
    }
}

更改后,代码可以在我的power Automation中触发http触发器。

是否有任何错误消息?是的,我找到了AgeTadrinfo ENOTFOUND,尽管我确信指向我的power Automation Httptrigger的链接是正确的。Hi Nicolai,似乎您不能在
选项中仅使用一个属性
主机名
。请参考我在下面提供的解决方案。是否有任何错误消息?是的,我找到了AgeTadrinfo ENOTFOUND,尽管我确信指向我的Power Automatic Httptrigger的链接是正确的。Hi Nicolai,似乎您不能在
选项中仅使用一个属性
主机名
。请参考我在下面提供的解决方案。