Microsoft Graph API 高于 5.44 - 属性:描述 - 返回 Microsoft.Kiota.Abstractions.Serialization.UntypedArray

问题描述 投票:0回答:1

通过使用 Microsoft Graph API 5.44,“描述”字段 (item.AdditionalData) 在返回时可以。 如果我使用高于 5.44 的 API,则该字段的值为 Microsoft.Kiota.Abstractions.Serialization.UntypedArray。

这是我的阅读方式...

User.Description = ReadAdditionalValueAttributeRS((Dictionary<string, object>)item.AdditionalData, "description"); 

部分代码...

try
{
    System.Text.Json.JsonElement jo = (System.Text.Json.JsonElement)newProp.Value;

-->>  newProp.Value = Microsoft.Kiota.Abstractions.Serialization.UntypedArray


    if (jo.ValueKind == System.Text.Json.JsonValueKind.String)
    {
        sval = jo.GetString();
        sResult = sval.Replace(Microsoft.VisualBasic.Constants.vbCrLf, @"\r\n");
        break;
    }
    else if (jo.ValueKind == System.Text.Json.JsonValueKind.Array)
    {
        var elementContentEnumerator = jo.EnumerateArray();
        while (elementContentEnumerator.MoveNext())
        {
            Console.WriteLine($"You are now at property {elementContentEnumerator.Current}");
            sval += elementContentEnumerator.Current.ToString();
            sval += " ";
        }
        sResult = sval.Trim().Replace(Microsoft.VisualBasic.Constants.vbCrLf, @"\r\n");
        break;
    }
}

可以检查这个值吗?

我当前切换回 Microsoft Graph API 5.44,而该值正常。 我使用版本 5.56、5.57 和 5.58 进行测试。返回值不行。

microsoft-graph-api attributes
1个回答
0
投票

UntypedNode
UntypedArray
UntypedString
UntypedInteger
UntypedBoolean
等的基类。所有
Untyped
类都有
GetValue()
方法,该方法返回无类型节点、字符串、int、或布尔值。

检查

newProp.Value
是否为
UntypedArray
UntypedString
,然后使用
GetValue()
读取值。

try
{
    if (newProp.Value is UntypedString untypedString)
    {
        sval = untypedString.GetValue();
        sResult = sval.Replace(Microsoft.VisualBasic.Constants.vbCrLf, @"\r\n");
        break;
    }
    else if (newProp.Value is UntypedArray untypedArray)
    {
        foreach (var item in untypedArray.GetValue())
        {
            if (item is UntypedString itemUntypedString)
            {
                sval += itemUntypedString.GetValue();
                sval += " ";
            }
        }
        sResult = sval.Trim().Replace(Microsoft.VisualBasic.Constants.vbCrLf, @"\r\n");
        break;
    }
}

恐怕 Graph SDK 团队没有很好地记录与

UntypedNode
的合作。

© www.soinside.com 2019 - 2024. All rights reserved.