HttpRunner HttpRunner 中执行 post 的接口测试,使用 Charles 抓包在 Query String 中参数怎么去除

张小川 · 2019年04月09日 · 最后由 张小川 回复于 2019年04月09日 · 1831 次阅读

问题描述:

使用 HttpRunner 发送 post 请求时,总是报错,Charles 抓包显示参数被添加在 Query String 后面
导致存在两个地方有参数,Query String 和 Form,导致接口请求报错
@testdev 请教,如何处理

[
    {
        "config": {
            "name": "testcase description",
            "variables": {}
        }
    },
   {
        "test": {
            "name": "发车接口",
            "setup_hooks": [
                "${calc_sign($request)}"
            ],
            "teardown_hooks": [
                "${set_infoid($response)}"
            ],
            "request": {
                "url": "http://dealercloudapi.che168.com/tradercloud/v190/carmanager/SaleCar.ashx",
                "method": "POST",
                "headers": {
                    "Content-Type": "application/x-www-form-urlencoded",
                    "User-Agent": "AutoTraderCloud/1.9.34 (iPhone; iOS 12.0; Scale/3.00)"
                },
                "data": {
                    "_appid": "atc.iphone",
                    "actionstate": "1",
                    "appversion": "1.9.34",
                    "brandid": "117",
                    "briefwords": "",
                    "buycid": "0",
                    "buyfrom": "0",
                    "buylinkmanid": "0",
                    "buylinkmanname": "",
                    "buypid": "0",
                    "buyprice": "12",
                    "buytime": "2019-04-09",
                    "buytype": "1",
                    "carname": "AC Schnitzer X5-2015款 ACS35 35i",
                    "caruse": "1",
                    "channelid": "$channelid",
                    "cid": "0",
                    "colorcode": "2",
                    "creditid": "0",
                    "csid": "100",
                    "detecterror": "",
                    "displa": "3.0",
                    "displayprice": "0",
                    "examine": "2021-04",
                    "floorprice": "0",
                    "fueltype": "0",
                    "gearbox": "自动",
                    "hasrechargeauth": "0",
                    "infoid": "0",
                    "innercolor": "1",
                    "innerstate": "1",
                    "insurance": "2019-04",
                    "invoice": "1",
                    "iscontainfee": "0",
                    "isopen": "0",
                    "ispicchange": "0",
                    "ispromise": "false",
                    "ispurchasetax": "0",
                    "isregiste": "0",
                    "keepstate": "10",
                    "keycount": "0",
                    "mileage": "0.1",
                    "outerstate": "1",
                    "pictures": "https://2sc2.autoimg.cn/escimg/g26/M09/F5/A4/u_autohomecar__ChcCP1yr-kKAEASNAAHiLZIFXS4677.jpg",
                    "pid": "0",
                    "price": "100",
                    "promisecontent": "",
                    "registedate": "2019-04",
                    "registration": "1",
                    "remark": "",
                    "saledealerprice": "0",
                    "seriesid": "2097",
                    "specid": "24355",
                    "syncsites": "0|",
                    "transfertimes": "0",
                    "udid": "$udid",
                    "userkey": "${get_userkey()}",
                    "xs_certify": "https://2sc2.autoimg.cn/escimg/g29/M06/F7/0C/u_autohomecar__ChsEflyr-nGAR1lgAAFGLnVJIJU099.jpg"
                }
            },
            "validate": [
                {
                    "eq": [
                        "status_code",
                        200
                    ]
                }
            ]
        }
    }
]
共收到 3 条回复 时间 点赞
张小川 关闭了讨论 04月09日 17:37
仅楼主可见
幺叁叁 回复

这个 json 就是直接用 Charles 导出来 har 文件,然后用 har2case 命令转的

张小川 关闭了讨论 04月09日 17:36
张小川 重新开启了讨论 04月09日 17:36
幺叁叁 回复

谢谢提醒,知道为什么出的问题了,是我在 debugtalk.py 中写的方法给参数赋值的时候用错 key 了

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册