得到开发提供的接口文档后,就可以开始写脚本了,如:
1. get请求的入参是json格式的
摘要: | 利用httpClient调用接口,成功返回信息 |
接口地址:(RESTFUL方式) | http://192.168.100.87:10051/ngcctcontrol/ws/interfaces/userSatisfy |
请求方式: | GET |
步骤: | 1、利用httpClient模拟接口调用正常情况。 |
输入报文: | { "params":{ "beginTime":"2017-01-01 00:00:00", "endTime":"2017-01-25 00:00:00", "userSatisfy":"1", "userSatisfy2":"1", "serviceTypeId":"otck" }, "object":[], "beans":[]}
{/"params/":{/"beginTime/":/"2017-01-01 00:00:00/",/"endTime/":/"2017-01-25 00:00:00/",/"userSatisfy/":/"1/",/"userSatisfy2/":/"1/",/"serviceTypeId/":/"otck/"},/"object/":[],/"beans/":[]} beginTime,endTime,不大于30天serviceTypeId//必传 |
要用URLencode转码,参见另一篇文章《jmeter json入参转化为get的入参》
2. get请求是普通的键值对
摘要: | 利用httpClient调用接口,成功返回异常信息
输入参数: staffId(必填):员工工号, toolBarType(必填):工具栏类型 00:接续栏, 01:场景栏, 02:工具栏
输出参数: toolBarType:工具栏类别编号 openModule:打开方式 displayNo:显示顺序 diaplayName:显示名称 typeId:按钮分类id menuId:菜单id parentId:父菜单id authId:权限编号 menuURL:按钮url imageURL:按钮图片url |
接口地址:(RESTFUL方式) | http://192.168.100.38:20037/ngmttcore/ws/auth/toolBar/ShortcutMenu |
请求方式: | GET |
这个很简单,只要用&链接符把他们一个个都放到URL里面就可以了
3,json格式的post请求
摘要: | 利用httpClient调用接口,成功返回信息 |
接口地址:(RESTFUL方式) | http://192.168.100.87:10051/ngcctcontrol/ws/interfaces/contactsingleope |
请求方式: | POST |
步骤: | 1、利用httpClient模拟接口调用正常情况。 |
输入报文: | { "params":{ "serialNo":"201701231140480000000000154926", "contactId":"201701231140480000000000154926", "channelId":"08000701", "channelName":"4G管家", "mediaTypeId":"01", "mediaTypeName":"webChat", "callType":"0", "PRovinceId":"00030001", "ctiId":" 1", "ccid":" 1", "vdnId":" 1", "callId":"14640099272192501", "callIdTime":"1464009927", "callIdDsn":"21925", "callIdHandle":"0", "callIdServer":" 1", "callSkillId":" 1", "callerNo":"psx34_163.com", "calledNo":"5323738", "subsNumber":"13837829820", "orgCallerNo":"", "orgCalledNo":"045110086", "staffId":"HA10031", "remark":"", "contactStartTime":"2017-01-23 11:40:48", "contactEndTime":"2017-01-23 16:35:55", "playRecordFlag":"0", "qcFlag":"0", "qcStaffId":" HA 10001", "staffHangup":" 1", "surveyTypeId":" 01", "userSatisfy":" 1", "userSatisfy2":" 1", "userSatisfy3":" 1", "hasRecordFile":" 1", "custId":"", "custName":"", "custLevelId":"", "custLevelName":"", "custBrandId":"", "custBrandName":"", "custCityId":" 000300010011 ", "custCityName":"昌平", "custCityId2":" 000300010012 ", "custCityName2":"大兴", "firstResponseTime":"2017-01-23 11:40:48", "fstCharAttrVal":"", "secdCharAttrVal":"", "thrdCharAttrVal":"", "fothCharAttrVal":"", "fithCharAttrVal":"", "sxthCharAttrVal":"", "svthCharAttrVal":"", "egthCharAttrVal":"", "nithCharAttrVal":"", "tenCharAttrVal":"", "elevCharAttrVal":"", "twlfCharAttrVal":"", "thtnCharAttrVal":"", "fotnCharAttrVal":"", "fitnCharAttrVal":"", "sitnCharAttrVal":"", "svtnCharAttrVal":"", "eitnCharAttrVal":"", "nitnCharAttrVal":"", "twthCharAttrVal":"", "toUserId":"sinaweibo2001627641", "toUserName":"中国移动", "fromOrgId":"", "releaseReason":"", "staffCityId":"99100000", "staffProvinceId":"00030050", "startRingTime":"", "serviceTypeId":"otck", "ctiCallId":"", "callTrace":"", "digitCode":"", "srFlag":"", "languageId":"", "languageName":"", "callSkillName":"4G管家,集中坐席", "workNo":"" }, "object":[], "beans":[]} |
4.post请求的键值对
有时候放到BodyData里,否则会报错,要放到URL里,用&连接符,类似情况2的get请求
新闻热点
疑难解答