简体   繁体   English

如何在邮递员中发送带有嵌套字段和文件的json

[英]how to send a json with neseted fields and files in postman

I need to send a json object like this :我需要发送一个这样的 json 对象:

 {
  
    "title": "tour1",
    "description": "lets go updated",
    "date_time": "2021-06-30T06:14:00Z",
    "time_zone": "Africa/Abidjan",
    "host": 1,
    "is_private": true,
    "is_virtual": false,
    "url": "www.google.com",
    "photos": [
        {
            "image": "http://127.0.0.1:8000/meeting-photos/1.jpg"
            
          
        },
        {
            "image": "http://127.0.0.1:8000/meeting-photos/5.jpg"
            
         
        },
        {
            "image": "http://127.0.0.1:8000/meeting-photos/3_Os8n2RX.jpg"
            
            
        }
    ],

   "location":{
     "lat": "0.0000000000000003",
     "lng": "0.0000000000000002"
    }
}

based on this question and answer i put the nested location field in bulk edit and the result was like this :基于此问题和答案,我将嵌套的位置字段进行了批量编辑,结果如下: 邮递员表格数据 but when i posted the json i got this error :但是当我发布 json 时,我收到了这个错误:

KeyError: 'location'

what should i do to solve this error?我应该怎么做才能解决这个错误?

One of your problems lie here:你的问题之一就在这里: 在此处输入图片说明

and you should not send " as key.并且您不应该发送 " 作为密钥。

You are treating form data like JSON, instead, you need to use it as key:value mapping.您正在像 JSON 一样处理表单数据,相反,您需要将其用作键:值映射。 See image below for how your request should look like:请参阅下图,了解您的请求应该是什么样子: 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM