簡體   English   中英

JSReport請求錯誤

[英]JSReport request 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"
    }
}   

這是我如何調用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))

有人知道會發生什么嗎? 我在任何地方都找不到任何資源。 先感謝您

您正在執行重復的JSON.stringify 像這樣刪除它:

const options = {
    method: 'POST',  
    headers: {
        'Authorization': 'Basic ' + hash,
        'Content-Type': 'application/json',
    },
    body: {
        template: { shortid: 'B1z8vSImQ' }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM