locust压测时提示:locust HTTPError('400 Client Error:xxxxx')

原因为data数据不是json类型,需要使用json.dumps(data)进行格式化,代码如下:

class UserBehavior(TaskSet):
  
    @task(1)
    def interface_1(self):
        headers = {"Content-Type": "application/json"}
        url = "/robat/cock/cock"
        data = { 
	    "taskid": "20180703101505551",
	    "uinid": "29007037"
        }
        aaa = json.dumps(data)
        self.client.post(url=url, data=aaa, headers=headers)

  

 

posted @ 2019-01-23 14:29  知了肥  阅读(1114)  评论(0编辑  收藏  举报