msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

Missing Post method path for /children

Open andrueastman opened this issue 2 years ago • 1 comments

    how can we do that with SDK v5.0.0 ?
var driveItem = new DriveItem
            {
                Name = path,
                Folder = new Folder(),
                AdditionalData = new Dictionary<string, object>() { { "@microsoft.graph.conflictBehavior", "fail" } }
            };
           
await graphClient.Sites[siteId].Drives[driveId].Root.Children.Request().AddAsync(driveItem);

Originally posted by @amarmechai in https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1290#issuecomment-1277775527

andrueastman avatar Oct 14 '22 07:10 andrueastman

https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/feature/5.0/src/Microsoft.Graph/Generated/Drives/Item/Root/Children/ChildrenRequestBuilder.cs#L85

Children request builder missing a Post method and will need to be fixed in the metadata.

This can be worked around by the snippet below as the metadata is fixed

var driveItem = new DriveItem
{
    Name = "path",
    Folder = new Folder(),
    AdditionalData = new Dictionary<string, object>() { { "@microsoft.graph.conflictBehavior", "fail" } }
};

var requestInformation = graphServiceClient.Drives["driveId"].Root.Children.CreateGetRequestInformation();
requestInformation.HttpMethod = Method.POST;
requestInformation.SetContentFromParsable(graphServiceClient.RequestAdapter, "application/json", driveItem);
await graphServiceClient.RequestAdapter.SendAsync<Drive>(requestInformation, Drive.CreateFromDiscriminatorValue);

andrueastman avatar Oct 14 '22 07:10 andrueastman

https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/feature/5.0/src/Microsoft.Graph/Generated/Drives/Item/Root/Children/ChildrenRequestBuilder.cs#L85

Children request builder missing a Post method and will need to be fixed in the metadata.

This can be worked around by the snippet below as the metadata is fixed

var driveItem = new DriveItem
{
    Name = "path",
    Folder = new Folder(),
    AdditionalData = new Dictionary<string, object>() { { "@microsoft.graph.conflictBehavior", "fail" } }
};

var requestInformation = graphServiceClient.Drives["driveId"].Root.Children.CreateGetRequestInformation();
requestInformation.HttpMethod = Method.POST;
requestInformation.SetContentFromParsable(graphServiceClient.RequestAdapter, "application/json", driveItem);
await graphServiceClient.RequestAdapter.SendAsync<Drive>(requestInformation, Drive.CreateFromDiscriminatorValue);

I tested this snippet of code and can confirm that this workaround functions correctly...

leoderja avatar Jan 12 '23 17:01 leoderja

Closed via https://github.com/microsoftgraph/msgraph-sdk-dotnet/pull/1639 and https://github.com/microsoftgraph/msgraph-metadata/issues/248

andrueastman avatar Feb 10 '23 06:02 andrueastman