51Testing软件测试论坛

标题: python运行接口报错,jmeter运行正常 [打印本页]

作者: 测试积点老人    时间: 2020-12-8 10:48
标题: python运行接口报错,jmeter运行正常
  1. import time

  2. import random

  3. import hashlib

  4. import requests

  5. import json

  6. #1.生成5位随机数

  7. phone=random.randint(10000,99999)

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

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

  10. print(timeStamp)

  11. optCode="testfan"

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

  13. t=str(phone+timeStamp)

  14. #4.sign=phoneNum+timeStamp+optCode

  15. sign=t+optCode

  16. #4.实例化一个md5对象

  17. md5=hashlib.md5()

  18. python运行后返回结果:

  19. {'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 [Source: (PushbackInputStream); line: 1, column: 10]", 'path': '/pinter/com/userInfo'}

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

  21. {"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
http://quan.51testing.com/pcQuan/chat/2864 参考下这个
作者: 郭小贱    时间: 2020-12-9 09:58
JMeter可以运行成功说明接口没问题啊,检查下Python代码呢
作者: bellas    时间: 2020-12-9 10:06
参考下这个链接https://blog.csdn.net/qq_40999727/article/details/103200939
作者: qqq911    时间: 2020-12-9 10:26
检查跑错信息
作者: jingzizx    时间: 2020-12-9 14:38
json有问题吧




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2