node.js - 节点 - 通过请求将 xml 发布到服务器
问题描述
我尝试通过 xmls 与 REST api 通信。我生成一个 xml 并使用Restlet Client(用于测试 REST API 的 chrome 扩展程序)对其进行测试。它工作正常,我收到响应 XML。如果我尝试使用request-promise发送,我会收到
'<html><head><title>Error</title></head><body>Internal Server Error</body></html>'
在 err.response.body 中。
API 服务器的响应始终是 XML,所以我不明白为什么它是“html”。
这是代码
options = {
uri: uri,
header: {
'Content-Type': 'application/xml ',
'Accept' : 'application/xml '
},
body: xml // I use the same xml in Restlet Client's body
}
rp.post(options).then(response=>{
console.log('------SUCCESS-----')
console.log(response)
}).catch(err=>{
console.log('------ERROR-----')
console.log(err.response)
})
如果您需要任何附加信息,请告诉我。
解决方案
推荐阅读
- php - 我正在尝试在 PHP 中压缩一个数组
- python - Python Social Auth Django 安装失败
- javascript - firestore 针对 id 数组检查 id 是否存在
- arrays - 难以查询具有多个元素的嵌套数组 Mongoose
- go - 接受 *[128]uint8、*[256]uint8 等的函数
- javascript - 了解带有 es6 模块的基本 webpack
- amazon-web-services - 在 aws elastic beanstalk docker 部署期间出现“内存错误”
- apache - Apache 2.4 LogLevel 和重写被忽略
- python - 将 Discord.py 中的角色列入黑名单
- r - 在 R 中使用 stringr::str_detect() 将不同的字符串与常见字符分开