简体   繁体   中英

GraphServiceClient, Create ContentVersions to intune with GraphServiceClient

I'm having trouble creating a new ContentVersion - Right now I have created a new entry with this code.

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

But I can't find the method to create a new ContentVersion. I know the URL, but not the method to call. The URL to call is this

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

So far I have tried to clone the github project ( https://github.com/microsoftgraph/msgraph-beta-sdk-dotnet ) to see how it works, but without luck. And right now, I just don't know where to look.

Any help would be appreciated

Okay, I solved it by doing it like this

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

Not sure if this is the correct way of doing it, but it works!

An alternative solution with a little less string concatenation:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM