如何通过 Postman 在 json 中插入多行?
我试过了:
[{
"name": "Choix 1",
"question": "Question 1"
},
{
"name": "Choix 3",
"question": "Question 44"
}
]
编辑。 我在文档中看到这是不可能的。
我在 API 中添加了一个非规范化组,现在由于 PATCH 方法,我可以同时添加多个数据。但是现在,问题是当我第二次添加时,它删除了之前的一部分数据。
示例:在“question_study”中,我的“question_id”156、157、160 没有任何“study_ID”,而在我向他发送一个新问题(161)之前,他们有一些,其 ID 号为 .. .. 如果我一次给他发几个,他们都有一个 study_id 但如果我再试一次,“study_id”就会消失......
axios
.patch('http://127.0.0.1:8000/api/studies/' + this.idStudy,
data,
{ headers: { 'Content-Type': 'application/merge-patch+json' }})
.then((result)=>{
console.log(result)
})
.catch(error => {
console.log("ERRRR:: ",error.result.data);
});
在我的控制台 console.log(result) 中:标题内容类型是“application/ld+json; charset=utf-8”,而我将“application/merge-patch+json”放入我的请求中。>
答案 0 :(得分:0)
如何通过 Postman [into ApiPlatform] 在 json 中插入多行?
不是。
至少,不使用 ApiPlatform 为其资源生成的默认路由。文档在这里:https://api-platform.com/docs/core/operations/
任何生成的 POST 路由都只接受一个资源。
如果您希望能够进行批量插入,则必须创建一个自定义端点,可能还需要创建一个集合非规范化器。