测试积点老人 发表于 2020-12-8 10:48:10

python运行接口报错,jmeter运行正常

import time

import random

import hashlib

import requests

import json

#1.生成5位随机数

phone=random.randint(10000,99999)

#2.生成13位数字的时间戳

timeStamp=int(round(time.time()*1000))

print(timeStamp)

optCode="testfan"

#3.随机数和时间戳拼接

t=str(phone+timeStamp)

#4.sign=phoneNum+timeStamp+optCode

sign=t+optCode

#4.实例化一个md5对象

md5=hashlib.md5()

python运行后返回结果:

{'timestamp': '2020-05-10T15:10:02.512+0000', 'status': 400, 'error': 'Bad Request', 'message': "JSON parse error: Unrecognized token 'phoneNum': was expecting ('true', 'false' or 'null'); nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'phoneNum': was expecting ('true', 'false' or 'null')\n at ", 'path': '/pinter/com/userInfo'}

jmeter运行后返回的正常结果:

{"code":"0","message":"success","data":{"id":2337,"userName":"性能测试","password":null,"age":80,"gender":1,"phoneNum":"39508","email":"beihe@testfan.com","address":"北京市昌平区科星西路106号院(国风美唐花园综合楼)3号楼1111","createTime":null,"updateTime":null}}

海海豚 发表于 2020-12-9 09:39:32

http://quan.51testing.com/pcQuan/chat/2864 参考下这个

郭小贱 发表于 2020-12-9 09:58:15

JMeter可以运行成功说明接口没问题啊,检查下Python代码呢

bellas 发表于 2020-12-9 10:06:19

参考下这个链接https://blog.csdn.net/qq_40999727/article/details/103200939

qqq911 发表于 2020-12-9 10:26:36

检查跑错信息

jingzizx 发表于 2020-12-9 14:38:10

json有问题吧
页: [1]
查看完整版本: python运行接口报错,jmeter运行正常