Using variables from scope: collection inside Postman works fine.
But when I export collection and use it inside Newman it does not work as I expected.
1) Variabes are inside collection json, in the end of file - ok.
2) I use this code:
var obj = {};
obj.categories = pm.variables.get("category_id");
obj.packages = pm.variables.get("package_id");
obj.type = "add";
pm.globals.set("switch_json", JSON.stringify(obj));
console.log("request body: " + pm.globals.get("switch_json"));
in pre-request script to get value of 2 collection variables (category_id, package_id).
3) Inside Postman all works fine, console.log return:
request body: {"categories":"14","packages":"2","type":"add"}
4) Inside Newman console.log return only:
'request body: {"type":"add"}'
Does it mean Newman do not support collection variables?
Collection Variables are stored in the variables tab in collections under Edit. Initial values are shared when you export a collection and not the current values. Newman will access these(initial Values) values.