问题描述
我在 Jira Script Runner 云中使用了以下代码片段
String _userId
def result = get(graph_base_user_url + "?")
.header("Authorization","Bearer " + AuthToken )
.queryString("\$filter","mail eq '$userEmail'")
.asJson()
if (result.getStatus().toString() =="200")
{
**if (result.getBody().value){ // <<<<< is Value is not empty ???
_userId=result.getBody().value[0].id
}**
else
_userId="-1" // user does not exist
}
// user ID not found : error 404
if (result.getStatus().toString()=="404")
_userId="User not found"
此代码在 result.getBody() 中返回以下输出
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users","value":[]}
我想要实现的是测试响应的值数组是否为空,如果不为空,我需要将第一个元素项作为 value[0].Id 获取,但我无法正确获取它
如何在上面的粗体中定义我的代码以执行正确的测试? 我从代码中得到的错误是:“值不是 JsonNode 对象的属性
感谢帮助 问候
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)