首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从TypeScript Azure函数调用MS Power Automate

从TypeScript Azure函数调用MS Power Automate
EN

Stack Overflow用户
提问于 2020-12-14 00:14:51
回答 1查看 97关注 0票数 1

如何从TypeScript Azure函数触发MS Power Automate HTTPtrigger。有没有人?我已经试过了,但是没有任何运气。

代码语言:javascript
复制
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()
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-14 16:41:43

options中,您似乎只使用了hostname属性,而没有使用portpath属性。我们不能将整个流程url放在optionshostname中,我们需要将它分离为hostnameportpath

例如,我的流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=mEAzy9xxxxxxxxxxxxxxxxxPqCwJBCc2mg,那么代码应该是这样的:

代码语言:javascript
复制
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 automate中触发http触发器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65277776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档