I try to test my web api via Postman
sandbox. I send simple post request and must get 400 or 200 status code in response. pre-request script :
var req_header = {
"Content-Type":"application/x-www-form-urlencoded"
};
var req_body = {
mode: 'urlencoded',
urlencoded: [
{key: "client_id", value : "----", disabled: false},
{key: "grant_type", value: "---", disabled: false},
{key: "username", value: "---", disabled: false},
{key: "password", value : "---", disabled: false},
] };
function StartBrutt (){
for (i=0;i < 100; i++){
pm.sendRequest({url:"https://...", method:'Post', header:req_header, body : req_body},
function (err, res) {
if (err) { console.log(err); }
pm.test(
'Get Response Code ',
function () {
pm.expect(pm.response.code).to.be.oneOf([200, 400]) //not worked
//pm.expect(pm.res!=null) worked good
});
});
}
}
StartBrutt();
But I always to get an error :
TypeError: Cannot read property 'code' of undefined
I use 6.1.3 version of desktop app.
Where is my Error ?
Aucun commentaire:
Enregistrer un commentaire