情景: - 我正在使用API进行负载测试
HTTP请求1
我使用http://cabhound.com:1000/v2/driver/login登录后得到以下回复
{"statusCode":200,"statusMessage":"Success","errorMessage":"","responseData":{"id":0,"userName":"PQeurentraps5S@tarento.com","firstName":"Partner","lastName":"Tarento","phoneNumber":"2641148625","email":"tamvrentrapnsr@tarento.com","password":"","addressOne":"","addressTwo":"","city":"","state":"","zipCode":"","loginCount":156,"welcome":"","smsOptIn":false,"promoCode":"","userNotification":"","errorMessage":"","message":"","sessionId":"6063tnerLt3013951671120oDse18492930#2","osType":"","osVersion":"","deviceType":"","deviceId":"","latitude":"","longitude":"","timeZone":"","appVersion":"","company":"Tarento","licenceNumber":"","vehicleType":"","vehicleFeature":null,"subscriptionType":"unlimited","driverWorkingCity":"Bangalore","vehicleNumber":"","locationUpdateTime":20,"rate":0,"reliable":0,"distance":0.0,"eta":0,"latitudeLongitude":"","status":"ON","payment":{"paymentType":"","cardNumber":"","cvnNumber":"","expDate":""},"vehicleTypeList":["Sedan","Limousine","SUV/Wagon","Minivan","Other"],"vehicleFeatureList":["Navigation System","Eco Friendly","Handicap accessible","Accepts credit cards"],"driverId":582,"currentLocation":null,"companyCode":"tarento","acceptanceRate":0,"like":0,"profileIndicator":0,"payWithCabHound":false,"smsSupport":false,"paymentInfo":false,"geoInfo":"","active":true}}
请参阅上述响应中的会话ID,我想在下一个http请求数据中使用
HTTP请求2
http://cabhound.com:1000/v2/driver/dutyStatus
以下是我需要发布的数据,这里我想使用HTTP Request 1的会话ID
{"status":"ON","sessionId":"1311tnerLt9013956793297oDse462783#2","longitude":"77.686700","userName":"erpkrentrapJps@tarento.com","latitude":"12.934487"}
如何将HTTP请求1(响应)的会话ID传递给HTTP请求2发布数据
帮助我解决这个问题
答案 0 :(得分:1)
我建议使用JSON Path Extractor提供的JMeter Plugin(你需要附加Libs Set的附加功能。
正则表达式很难开发,特别是对于可以多线的JSON数据。 Beanshell已知性能问题,因此使用插件是最佳选择。
您的sessionId的相关JSON路径查询将显示为:
$.responseData.sessionId
有关详细信息和XPath到JSON路径映射,请参阅使用XPath Extractor in JMeter指南的Parsing JSON
部分
答案 1 :(得分:0)
我可以看到针对上述问题的两种解决方案,