小编Aar*_*ani的帖子

向 Redmine API 发送 POST 请求时如何修复“422 Unprocessable Entity”?

我正在尝试使用 redmine Rest api 创建一个 wiki 页面。身份验证已成功,但由于 422 错误,未创建 wiki 页面。

Redmine 文档说:“当尝试创建或更新属性参数无效或缺失的对象时,您将收到 422 Unprocessable Entity 响应。这意味着无法创建或更新该对象。”

但我似乎可以找出我哪里搞砸了。当我执行第二个请求“PUT REQUEST”时,问题出现了。

所以我们知道问题出在该部分的某个地方。

我的猜测是,它是文件路径或内容类型。

这就是我到目前为止所拥有的......

const wordDocument="C:\Users\adasani\Desktop\practice\RedmineApi/RedmineText.txt";

creatingWikiPage_Request(wordDocument);

function creatingWikiPage_Request(wordDocument) {

    axios({
        method: 'post',
        url: '<redmine_url>/uploads.json',
        headers: { 'Content-Type': 'application/octet-stream' },
        params: { 'key': '<api-key>' },
        data: wordDocument
    })
        .then(function (response) {
            console.log("succeeed--->  ");
            console.log(response.data.upload.token)
            axios({
                method: 'put',
                url: '<redmine_url>/projects/Testing/wiki/WikiTesting.json',
                headers: { 'Content-Type': 'application/octet-stream' },
                params: { 'key': '<api-key>' },
                data: {

                    "wiki_page": {
                        "text": "This is a wiki page with images, and …
Run Code Online (Sandbox Code Playgroud)

file-upload redmine redmine-api axios http-status-code-422

4
推荐指数
1
解决办法
9万
查看次数