使用rally-node在讨论中创建ConverationPost

时间:2019-02-15 17:06:54

标签: node.js rally

如何在现有的用户案例中创建ConverationPost?

我似乎无法正确理解语法:

const create = {
  type: 'ConversationPost',
  data: {
    Text: 'api test comment',
    Artifact: '/hierarchicalrequirement/287838839156'
  }
};
restApi.create(create)
.then(result => {
  console.log(result);
})
.catch(error => {
  console.error(error);
})

错误始终是:

{ Error: /ConversationPost/create: 401! body=undefined
    at generateError (/Users/ts/Sites/node/tests/node_modules/rally/dist/request.js:38:11)
    at Request._callback (/Users/ts/Sites/node/tests/node_modules/rally/dist/request.js:114:20)
    at Request.self.callback (/Users/ts/Sites/node/tests/node_modules/request/request.js:185:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/Users/ts/Sites/node/tests/node_modules/request/request.js:1161:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Gunzip.<anonymous> (/Users/ts/Sites/node/tests/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:313:30) errors: [ '/ConversationPost/create: 401! body=undefined' ] }```

当我在使用Rally GUI手动创建帖子的同时查看开发工具时,我在请求正文中看到了这一点:

{
  "ConversationPost": {
    "Text": "testing",
    "Artifact": "/hierarchicalrequirement/287838839156"
  }
}

有人知道该怎么做吗?

编辑:

request调试设置为true会在请求中显示这一点,看起来很正确:

  json: 
   { ConversationPost: 
      { Text: 'api test comment',
        Artifact: '/hierarchicalrequirement/287838839156' } },
  gzip: true,
  url: 'https://rally1.rallydev.com/slm/webservice/v2.0/ConversationPost/create',
  qs: {},
  callback: [Function],
  method: 'POST' }

我应该添加401似乎很奇怪,因为我可以针对该用户故事进行查询。

我还注意到,拉力赛节点模块发出的请求是POST请求,但是在我的浏览器中,GUI是否会发出PUT请求?

1 个答案:

答案 0 :(得分:0)

结果证明这是正确的。令人讨厌的小字样是,在Rally中配置API密钥时,“ ALM WSAPI只读”使Rally忽略第二个设置。

401错误与“访问被拒绝”相对应,也就是密钥或密钥权限出现问题。