GET、POST、PUT、DELETE请求测试项

利用的是命令行cscript  **.js

GET

var httpRequest = new ActiveXObject("Microsoft.XMLHTTP");

httpRequest.open("GET", "http://localhost:8088/budgetExecuteItem/get", false);

var data=["id=8"];

httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  //默认form的字符串传送数据
//httpRequest.setRequestHeader("Content-Type", "application/json"); //JSON数据
httpRequest.send(data.join('&'));
//httpRequest.send(JSON.stringify(data));


WScript.Echo(httpRequest.responseText);


POST

var httpRequest = new ActiveXObject("Microsoft.XMLHTTP");

httpRequest.open("POST", "http://localhost:8088/budgetExecuteItem/post", false);


var data ='{"id":"1","budgetId":"1","projectId":"1","typeLevel1":"3","typeLevel2":"3","typeLevel3":"3","typeLevel4":"TTTTT","budgetCode":"BBBBB","money":"3000","executeTime":"2017-11-06","remarks":"xxxx"}';
//httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");


httpRequest.setRequestHeader("Content-Type", "application/json");
//httpRequest.send(data.join('&'));
 
//httpRequest.send(JSON.stringify(data)); 
httpRequest.send(data);


WScript.Echo(httpRequest.responseText);


PUT

var httpRequest = new ActiveXObject("Microsoft.XMLHTTP");




httpRequest.open("PUT", "http://localhost:8088/budgetExecuteItem/put", false);


var data ='{"id":"1","budgetId":"1","projectId":"1","typeLevel1":"3","typeLevel2":"3","typeLevel3":"3","typeLevel4":"YYYY","budgetCode":"AAAA","money":"6000","executeTime":"2017-11-06","remarks":"xxxx"}';
//httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");


httpRequest.setRequestHeader("Content-Type", "application/json");
//httpRequest.send(data.join('&'));
 
//httpRequest.send(JSON.stringify(data)); 
httpRequest.send(data);


WScript.Echo(httpRequest.responseText);


DELETE

var httpRequest = new ActiveXObject("Microsoft.XMLHTTP");




httpRequest.open("DELETE", "http://localhost:8088/budgetExecuteItem/delete?id=1", false);


var data=["id=1"];


httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//httpRequest.setRequestHeader("Content-Type", "application/json");
httpRequest.send();
//httpRequest.send(JSON.stringify(data));


WScript.Echo(httpRequest.responseText);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值