无法从负载中的变量/JSON 文件传递值
我试图在有效负载下方传递一个值,我可以从打印中获取它的值,但在有效负载内部无法访问相同的值,它会打印 #(config.Secondary_ED) 作为输出。 config.Secondary_ED 包含一个 IP 地址。当我手动提供 IP 地址时,它工作正常。
And print config.Secondary_ED
And request {"agent-forwarding":true,"configuration-data":"{\"service-host\":\"#(config.Secondary_ED)\",\"service-port\":\"8443\",\"user\":\"restdispatcher\",\"protocol\":\"vosrestdispatcher:rest\"}","configuration-template":null,"description":"Change Guardian Default Event Destination sk-12sp5","display-name":"sk-12sp5","ev-prototype-id":"1","forwarding-queries":[""],"id":1,"is-default":true,"is-indelible":true,"method":"vosrestdispatcher:rest","model":"REST Dispatcher","server-fordwarding":false}
When method PUT
工作负载
#And print config.Secondary_ED
And request {"agent-forwarding":true,"configuration-data":"{\"service-host\":\"1.1.1.1\",\"service-port\":\"8443\",\"user\":\"restdispatcher\",\"protocol\":\"vosrestdispatcher:rest\"}","configuration-template":null,"description":"Change Guardian Default Event Destination sk-12sp5","display-name":"sk-12sp5","ev-prototype-id":"1","forwarding-queries":[""],"id":1,"is-default":true,"is-indelible":true,"method":"vosrestdispatcher:rest","model":"REST Dispatcher","server-fordwarding":false}
**Secondary_ED 存储在名为 config.js 的 json 文件中
我已经多次使用 # 来获取值,但在这种情况下同样不起作用。 请建议我在这里错过了什么。
感谢您的帮助。
I am trying to pass a value inside below payload, I am able to get the value of it from the print but same is not accessible inside the payload, It prints the #(config.Secondary_ED) as the output.
The config.Secondary_ED contains an ip address. It works fine when I give ip address manually.
And print config.Secondary_ED
And request {"agent-forwarding":true,"configuration-data":"{\"service-host\":\"#(config.Secondary_ED)\",\"service-port\":\"8443\",\"user\":\"restdispatcher\",\"protocol\":\"vosrestdispatcher:rest\"}","configuration-template":null,"description":"Change Guardian Default Event Destination sk-12sp5","display-name":"sk-12sp5","ev-prototype-id":"1","forwarding-queries":[""],"id":1,"is-default":true,"is-indelible":true,"method":"vosrestdispatcher:rest","model":"REST Dispatcher","server-fordwarding":false}
When method PUT
Working Payload
#And print config.Secondary_ED
And request {"agent-forwarding":true,"configuration-data":"{\"service-host\":\"1.1.1.1\",\"service-port\":\"8443\",\"user\":\"restdispatcher\",\"protocol\":\"vosrestdispatcher:rest\"}","configuration-template":null,"description":"Change Guardian Default Event Destination sk-12sp5","display-name":"sk-12sp5","ev-prototype-id":"1","forwarding-queries":[""],"id":1,"is-default":true,"is-indelible":true,"method":"vosrestdispatcher:rest","model":"REST Dispatcher","server-fordwarding":false}
**Secondary_ED is stored in a json file called config.js
I have used # many times to get the value but same doesn't work in this case.
Please suggest what did I miss here.
Appreciate your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意,
configuration-data
的值是一个字符串,而不是 JSON 对象。如果不清楚请教懂JS的朋友。你可以尝试这个(注意
string
的用法):或者只使用 JS 字符串连接(这只是一个猜测,请弄清楚什么对你有用,但你明白了。
Please notice that the value of
configuration-data
is a string, not JSON object. Ask a friend who knows JS if this is not clear.You can try this (note the usage of
string
):Or just use JS string concatenation (this is just a guess, please figure out what works for you, but you get the idea.