邮递员未在控制台中返回实际值 [英] postman not returning the actual value in console

查看:99
本文介绍了邮递员未在控制台中返回实际值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置全局环境变量,但邮递员未设置该值。
我写的脚本是

I am trying to set up a global environment variable, but postman is not setting the value. The script I wrote is

var jsonObject = xml2Json(responseBody);
console.log(jsonObject);
console.log(jsonObject.CreatePOReq.$.ProjectNumber);

pm.globals.set(("ofs_projectNumber", jsonObject.CreatePOReq.$.ProjectNumber));
console.log(pm.globals.get("ofs_projectNumber"));

但是我在控制台中得到的内容非常不同-最后两行应该相同,但是它不是。我在做什么错

But What I am getting in the console is very different - the last 2 lines should be identical, but it is not. What am I doing wrong

推荐答案

这里有两个大括号。并请在下面检查附件

Here two curly braces are there. and please below check attachment

     pm.globals.set(("ofs_projectNumber", jsonObject.CreatePOReq.$.ProjectNumber));

而不是在下面使用。

     pm.globals.set("ofs_projectNumber", jsonObject.CreatePOReq.$.ProjectNumber);

这篇关于邮递员未在控制台中返回实际值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆