我正在尝试使用 npm 包向Highrisenode-highrise-api
API 发出发布请求。它需要 XML,我一直从 API 获得响应,但未成功传递数据。这是我的代码:
studentNote = "<note><body>hello</body><subject-id type=\"integer\">267869152</subject-id><subject-type>Status Change</subject-type></note>"
rp.post "https://token:a@name.highrisehq.com/people/id/notes.xml", studentNote
.then (response) ->
highriseData = xml2js.parseStringAsync response, {trim: true}
console.log highriseData
.catch (err) ->
console.log 'this err'
console.log err
null
rp 是 request-promise,一个 npm 包,它通过 request npm 包启用承诺。
回应是:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<author-id type="integer">1232986</author-id>
<collection-id type="integer" nil="true"></collection-id>
<collection-type nil="true"></collection-type>
<created-at type="datetime">2016-09-22T20:52:16Z</created-at>
<group-id type="integer" nil="true"></group-id>
<id type="integer">381833222</id>
<owner-id type="integer" nil="true"></owner-id>
<subject-id type="integer">267869152</subject-id>
<subject-type>Party</subject-type>
<updated-at type="datetime">2016-09-22T20:52:16Z</updated-at>
<visible-to>Everyone</visible-to>
<body nil="true"></body>
<subject-name>Parentof Student</subject-name>
</note>
如果您查看正文、主题 ID 和主题类型标签,我传递的数据不会在响应中发回。
有人对处理 XML API 有什么建议吗?
提前致谢