Hello,
I have a very strange problem. I’m trying to run postman collection converted to js script, using scenarios. The problem is that I can’t use global variables in two request from one scenario. I mean, in the first request the variable is used in the body without a problem, then when I use it in the second request I get “panic: interface conversion: goja.valueString is goja.asciiString, not goja.unicodeString goroutine 45” following with a big stack trace.
Here is the code snipped where I set the global variables:
export let options = {
maxRedirects: 4,
scenarios: {
radostina_user: {
executor: 'constant-vus',
vus: 1,
duration: '2s',
exec: 'radostina_user_test',
},
},
};
var i;
for (i = 0; i < csvData.length - 2; i = i + 2)
{
if(i===0){
pm.globals.set("phoneR", csvData[i]);
pm.globals.set("otpSeR", csvData[i + 1]);
}
}
Here are the requests:
export function radostina_user_test() {
postman[Request]({
name: "QueryPhone",
id: "9tshhfghf",
method: "POST",
address: "https://test/api/queryPhone",
data:
'{\n "phoneNumber": "{{phoneR}}",\n "otpSession": "{{**otpSeR**}}"\n}',
headers: {
Date: "2020-05-20T15:22:00",
"Content-Type": "application/json",
"Accept-Language": "en_EN",
"Api-version": "v1",
deviceinfo:
"eyJhcHBWZXJzaW9uIjoiMC4xLjU4Iiwib3MiOiJpb3MiLCJwdXNoVG9rZW4iOiJkZUpTMl9YQ1JKSTpBUEE5MWJGRE50OXk5b05CQWZvMVZSWXdpNklRUkVMUlhUN3NyZWxVcHR5VVNYWWo4S295ekxSU3RsdndSMERJa3UwdTFNUWVTVm5BX1JsY2t1SDhPTmZsbWxfLWFwWHNtSjVFMXRRRUhubGo5QVU0UHpVY0lNNFQ0LWtGeWJ2LUVNaHBCYU1VSVNSVSIsIm9zVmVyc2lvbiI6IjExLjQuMSIsIm1vZGVsIjoiaVBob25lIDYiLCJ1ZGlkIjoiN0NDRDg4NzMtQzdBMC00QjI4LTkyMjItNjVBRURGNEUxM0M5IiwiaXNSb290ZWQiOmZhbHNlLCJicmFuZE5hbWUiOiJBcHBsZSIsInNjcmVlblJlc29sdXRpb24iOiIzNzUuMC02NjcuMCJ9"
},
post(response) {
var data2 = pm.response.code;
var data = pm.response.json();
console.log("QueryPhone Radostina " + data2 + " " + JSON.stringify(data));
pm.globals.set("username", data.username);
pm.globals.set("userId", data.userId);
if (data2 != 200) {
console.log("QueryPhone " + data2 );
};
}
});
postman[Request]({
name: "AuthorizUp",
id: "c8gw454w5y4hh",
method: "POST",
address: "https://test/auth/loginUp",
data:
'{"username": "{{username}}" ,"password": "12345","otpSession": "{{**otpSeR**}}"}',
headers: {
Date: "2020-05-20T15:22:00",
"Accept-Language": "en_EN",
"Content-Type": "application/json",
deviceInfo:
"eyJvcyI6ImFuZHJvaWQiLCJvc1ZlcnNpb24iOiI4LjEuMCIsImJyYW5kTmFtZSI6IlhpYW9taSIsIm1vZGVsIjoiUmVkbWkgNiIsInVkaWQiOiJiNTAxYzU4M2MwNDBiOGI2Iiwic2NyZWVuUmVzb2x1dGlvbiI6IjcyMHgxMzQ0LTMyMGRwaS14aGRwaSIsImFwcFZlcnNpb24iOiJ2MC4xLjExMy1pbnRlcm5hbCIsImlzUm9vdGVkIjpmYWxzZX0="
},
post(response) {
var data = pm.response.json();
var data2 = pm.response.code;
pm.globals.set("access_token", data.accessToken);
pm.globals.set("refresh_token", data.refreshToken);
console.log("Login " + data2 + " " + JSON.stringify(data) );
if (data2 != 200) {
console.log("Login " + data2 );
};
}
});
It can be seen that I’m using “otpSeR” variable in the two request. I get the error message in the second one. If I hardcode the value of the variable and not using the variable name in the second request, everything is working fine. But when I use the variable I got this strange error message.
I can upload the whole stack trace message if this will help.
I would appreciate it if you could help me.
Best regards
p.s. Sorry I can’t find a way to properly format my code snipped.