microsoftgraph / msgraph-sdk-serviceissues

Tracks service issues for follow up.
5 stars 0 forks source link

Delete of MobileAppRelationship not working #88

Open dansmitt opened 3 years ago

dansmitt commented 3 years ago

Case 1: Application has a parent MobileAppRelationship and a child MobileAppRelationship. You want to delete the child MobileAppRelationship. Error:

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. Status Code: BadRequest Microsoft.Graph.ServiceException: Code: BadRequest Message: { "_version": 3, "Message": "A circular dependency was created while adding app relationships. - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: 6a972f4f-ea00-4475-99c1-ca7af80d517e - Url: https://fef.msub01.manage.microsoft.com/AppLifecycle_2104/StatelessAppMetadataFEService/deviceAppManagement/mobileApps%28%276d760768-7f25-4b58-b747-40c1d92de5b2%27%29/microsoft.management.services.api.updateRelationships?api-version=5020-11-17", "CustomApiErrorPhrase": "", "RetryAfter": null, "ErrorSourceService": "", "HttpHeaders": "{}" } Inner error: AdditionalData: date: 2021-04-15T09:49:58 request-id: 6a972f4f-ea00-4475-99c1-ca7af80d517e client-request-id: 6a972f4f-ea00-4475-99c1-ca7af80d517e ClientRequestId: 6a972f4f-ea00-4475-99c1-ca7af80d517e

at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption) at Microsoft.Graph.BaseRequest.SendAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption) at BASF.ApplicationManagementToolLib.Intune.Base.ApplicationIntuneGraph.RemoveDependencyAsync(String sourceId, String targetId) in C:\Dev\Git\ApplicationManagementTool\Test\ApplicationIntuneGraph.cs:line 76 at Test.Controllers.WeatherForecastController.Get() in C:\Dev\Git\ApplicationManagementTool\Test\Controllers\WeatherForecastController.cs:line 31 at lambda_method(Closure , Object ) at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult() at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gLogged|12_1(ControllerActionInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gAwaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.gAwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context) fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]

Case 2: Application has a parent MobileAppRelationship and a child MobileAppRelationship. You want to delete the parent MobileAppRelationship. Result: No error but dependency is still existing in Intune.

Case 3: Application has a child MobileAppRelationship and no parent MobileAppRelationship. You want to delete the child MobileAppRelationship. Result: Works.

Code:

        public async Task RemoveDependencyAsync(string sourceId, string targetId)
        {
            var requestBuilder = new MobileLobAppRequestBuilder(_graphClient.DeviceAppManagement.MobileApps[sourceId].RequestUrl, _graphClient);

            List<MobileAppRelationship> dependenciesTo = (await _graphClient.DeviceAppManagement.MobileApps[sourceId].Relationships.Request().GetAsync()).ToList();

            MobileAppRelationship remDep = dependenciesTo.Where(x => x.TargetId == targetId).FirstOrDefault();
            dependenciesTo.Remove(remDep);

            var req = requestBuilder.UpdateRelationships(dependenciesTo).Request();

            try
            {
                await req.PostAsync();
            }
            catch (Exception ex)
            {
                throw;
            }
        }

Shouldn't it be possible to delete dependencies in both ways? Issue is persitent in 0.4x and 4.x

AB#9006

dansmitt commented 3 years ago

@andrueastman any updates here? We need to implement this for our project.

petrhollayms commented 2 months ago

Thank you for reporting this issue. This appears to be an issue or limitation with the service APIs. Unfortunately, as the Microsoft Graph SDK team, we do not have ownership of the APIs that are causing you issues. We invite you to create a question about the service API to Microsoft Q&A and tagged with one of the [microsoft-graph-*] tags, that way it will get routed to the appropriate team for them to triage:

https://aka.ms/msgraphsupport or directly https://aka.ms/askgraph

For now, we will close the issue on our side but feel free to open it in the relevant repository if you think the issue is specific to SDK. Please let us know if this helps!

Note: We will close this repository on April 19, 2024.