[英]Sending (nested) json object with file using Postman
使用 Postman,我可以在請求中附加帶有表單數據的文件,我還可以發送原始格式的嵌套 JSON 對象,但我怎樣才能做到這兩點:發送帶有文件的嵌套結構數據,例如:
"data": {
"normal_fields": {
"field1": "value1",
"field2": "value2"
},
"image_file": <file>
}
嘗試設置如下值並選擇要上傳的文件。
它對我不起作用。 對我來說,只有這樣工作:
property[nested_field1]
property[nested_field2]
或帶有對象的數組:
array[0][nested_field1]
array[0][nested_field2]
array[1][nested_field1]
array[1][nested_field2]
如果有人需要發送一組文件,這種語法對我有用:
<field_name>[0]
<field_name>[1]
...
<field_name>[n]
但是,如果您將文件作為嵌套對象數組發送:即
{
"files": [
{
"file": <file>
},
{
"file": <file>
},
]
}
然后試試這個:
files[0]file
files[1]file
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.