C# GetById的Microsoft.Graph方法未返回包含其所有属性的完整对象

C# GetById的Microsoft.Graph方法未返回包含其所有属性的完整对象,c#,azure-active-directory,microsoft-graph-api,C#,Azure Active Directory,Microsoft Graph Api,在我的项目中,我使用Microsoft.Graph API的GetByIds方法和选择字符串,它工作正常,返回选择字符串中提到的所有属性。但最近,它已停止工作,并且没有返回包含选择字符串中提供的所有属性的完整对象。即使我没有提供Select,也不会完全返回属性,特别是我需要的属性,如accountenabled、BusinessPhone、city、companyname、country、department、jobtitle。这种方法对我的项目非常重要,Microsoft在其后端Microso

在我的项目中,我使用Microsoft.Graph API的GetByIds方法和选择字符串,它工作正常,返回选择字符串中提到的所有属性。但最近,它已停止工作,并且没有返回包含选择字符串中提供的所有属性的完整对象。即使我没有提供Select,也不会完全返回属性,特别是我需要的属性,如accountenabled、BusinessPhone、city、companyname、country、department、jobtitle。这种方法对我的项目非常重要,Microsoft在其后端Microsoft.Graph API中出现了错误。请问,有人能帮我找到一个替代方法,这个方法获取用户ID列表并返回他们的所有属性吗?Microsoft是否有任何ETA可以使用此GetByIds方法修复此问题

我的代码如下:

var directoryObjects = new List<Microsoft.Graph.DirectoryObject>();
var types = new List<String>()
            {
                "user"
            };
string select ="displayname,mail,mailnickname,onpremisessecurityidentifier,onpremisessyncenabled,proxyaddresses,id,odatatype,accountenabled,businessphones,city,companyname,country,department,givenname,imaddresses,jobtitle,mobilephone,onpremisesimmutableid,passwordpolicies,officelocation,postalcode,preferredlanguage,state,streetaddress,surname,usagelocation,userprincipalname,usertype";

var responseWithSelect = _graphServiceClient.DirectoryObjects.GetByIds(identitiesList,types).Request().Select(select).PostAsync().Result;

var responseWithoutSelect = _graphServiceClient.DirectoryObjects.GetByIds(identitiesList,types).Request().PostAsync().Result;

如图所示:

使用从ID列表中获取目录对象请求对象 应该返回完整的对象。但是,当前 返回的v1.0端点包含一组有限的属性。作为一个 临时解决方法,当您将该操作与 使用$select查询选项,将返回更完整的用户对象。 此行为不符合OData规范。 由于此行为将来可能会更新,请使用 仅当您为所有属性提供$select=时的解决方法 只有在未来发生重大变化时,我们才会对此感兴趣 解决方法是可以接受的

我用Fiddler监视请求。我发现实际的请求是:

POST https://graph.microsoft.com/v1.0/directoryObjects/microsoft.graph.getByIds?$select=displayname,mail,mailnickname,onpremisessecurityidentifier,onpremisessyncenabled,proxyaddresses,id,odatatype,accountenabled,businessphones,city,companyname,country,department,givenname,imaddresses,jobtitle,mobilephone,onpremisesimmutableid,passwordpolicies,officelocation,postalcode,preferredlanguage,state,streetaddress,surname,usagelocation,userprincipalname,usertype HTTP/1.1
SdkVersion: Graph-dotnet-1.18.0
FeatureFlag: 0000004F
Cache-Control: no-store, no-cache
Authorization: Bearer eyJ0eXAiOiJKV1Qi*****************X5Q
Accept-Encoding: gzip
Content-Type: application/json
Host: graph.microsoft.com
Content-Length: 65
Expect: 100-continue

{"ids":["ab6d4cd6-fc2d-40c7-a676-f8773aebfb5f"],"types":["user"]}
但是,在响应中,并没有返回所有必需的属性。甚至displayname也没有返回。我进一步检查,发现实际的属性名是displayName。所以,我把它改成了正确的,并且我能够得到返回的displayName

所以

API本身存在一些已知问题,这些问题阻止它返回请求的值

select字符串现在区分大小写


您可以相应地更改代码,看看是否有帮助

哦,你说得对。现在此方法采用区分大小写的选择字符串属性,而以前它不区分大小写。非常感谢您为我指明了正确的方向,这是我以前没有想到的,因为所有其他请求方法(如GetAsync)仍然能够使用不区分大小写的选择字符串属性。我将相应地更新我的代码。如果答案对您有帮助,您可以接受它作为答案单击答案旁边的复选标记将其从灰色变为填充。这可能对其他社区成员有益。非常感谢。