GraphServiceClient,创建ContentVersions以与GraphServiceClient配合使用

时间:2020-03-03 21:13:54

标签: c# .net-core microsoft-graph-api

我在创建新的ContentVersion时遇到问题-现在,我已使用此代码创建了一个新条目。

var newItem = await client.DeviceAppManagement.MobileApps.Request().AddAsync(new Win32LobApp {});

但是我找不到创建新ContentVersion的方法。我知道URL,但不知道调用方法。 调用的URL是这个

POST: https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/{0}/microsoft.graph.win32LobApp/contentVersions

到目前为止,我已经尝试克隆github项目(https://github.com/microsoftgraph/msgraph-beta-sdk-dotnet)来了解它的工作原理,但是没有运气。而现在,我只是不知道在哪里看。

任何帮助将不胜感激

2 个答案:

答案 0 :(得分:0)

好的,我这样解决了

ManagedMobileLobAppRequestBuilder builder = new ManagedMobileLobAppRequestBuilder($"{client.BaseUrl}/deviceAppManagement/mobileApps/{newItem.Id}/{newItem.ODataType.Substring(1)}", client);
var result = await builder.ContentVersions.Request().AddAsync(new MobileAppContent());

不确定这样做是否正确,但是可以!

答案 1 :(得分:0)

另一种减少字符串连接的解决方案:

var lobType = createAppResult.ODataType.Substring(1);
var baseUrl = client.DeviceAppManagement.MobileApps[appId].AppendSegmentToRequestUrl(lobType)
var lobRequestBuilder = new ManagedMobileLobAppRequestBuilder(baseUrl, client);