[英]JSReport request error
I am trying to access the jsreport api to render a report template and I am getting the following error: 我正在尝试访问jsreport api来呈现报告模板,但出现以下错误:
{
body: "{"body":"\"{\\\"template\\\":{\\\"shortid\\\":\\\"B1z8vSImQ\\\"}}\"","status":400,"statusCode":400}",
code: 500,
headers: {
connection: "close",
content-length: "99",
content-type: "application/json; charset=utf-8",
date: "Mon, 16 Jul 2018 14:22:54 GMT",
etag: "W/"63-y7OYa6jmSZpY//j8j8VDr2CKCZg"",
server: "nginx/1.15.0",
x-powered-by: "Express"
}
}
Here is how I am calling the api: 这是我如何调用api:
const options = {
method: 'POST',
//strictSSL: false,
headers: {
'Authorization': 'Basic ' + hash,
'Content-Type': 'application/json',
},
body: JSON.stringify({
template: { shortid: 'B1z8vSImQ' }
}),
// auth: {
// username,
// password
// }
}
requestify.request('https://gabrielsch.jsreportonline.net/api/report', options)
.then(response => {
})
.catch(error => console.log(error))
Does anyone know what might be happening? 有人知道会发生什么吗? I can't find any resource on this anywhere. 我在任何地方都找不到任何资源。 Thank you in advance 先感谢您
You are doing duplicated JSON.stringify
. 您正在执行重复的JSON.stringify
。 Remove it like this: 像这样删除它:
const options = {
method: 'POST',
headers: {
'Authorization': 'Basic ' + hash,
'Content-Type': 'application/json',
},
body: {
template: { shortid: 'B1z8vSImQ' }
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.