【问题标题】:how to send a json with neseted fields and files in postman如何在邮递员中发送带有嵌套字段和文件的json
【发布时间】:2021-09-17 03:19:48
【问题描述】:

我需要像这样发送一个 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"
    }
}

基于此question and answer ,我将嵌套位置字段进行批量编辑,结果如下: 但是当我发布 json 时,我得到了这个错误:

KeyError: 'location'

我应该怎么做才能解决这个错误?

【问题讨论】:

    标签: json postman


    【解决方案1】:

    您的问题之一在于:

    而且你不应该发送 " 作为键。

    您将表单数据视为 JSON,相反,您需要将其用作键:值映射。请参阅下图了解您的请求的外观:

    【讨论】:

      猜你喜欢
      • 2014-12-29
      • 2019-05-13
      • 2020-10-30
      • 1970-01-01
      • 2017-11-28
      • 2018-09-12
      • 1970-01-01
      • 1970-01-01
      • 2021-10-22
      相关资源
      最近更新 更多