/// <summary> /// Updates the specified ManagedAppRegistration using PATCH. /// </summary> /// <param name="managedAppRegistrationToUpdate">The ManagedAppRegistration to update.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception> /// <returns>The updated ManagedAppRegistration.</returns> public async System.Threading.Tasks.Task <ManagedAppRegistration> UpdateAsync(ManagedAppRegistration managedAppRegistrationToUpdate, CancellationToken cancellationToken) { if (managedAppRegistrationToUpdate.AdditionalData != null) { if (managedAppRegistrationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || managedAppRegistrationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, managedAppRegistrationToUpdate.GetType().Name) }); } } if (managedAppRegistrationToUpdate.AdditionalData != null) { if (managedAppRegistrationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || managedAppRegistrationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, managedAppRegistrationToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <ManagedAppRegistration>(managedAppRegistrationToUpdate, cancellationToken).ConfigureAwait(false); return(updatedEntity); }
/// <summary> /// Adds the specified ManagedAppRegistration to the collection via POST. /// </summary> /// <param name="managedAppRegistration">The ManagedAppRegistration to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created ManagedAppRegistration.</returns> public System.Threading.Tasks.Task <ManagedAppRegistration> AddAsync(ManagedAppRegistration managedAppRegistration, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; managedAppRegistration.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(managedAppRegistration.GetType().FullName)); return(this.SendAsync <ManagedAppRegistration>(managedAppRegistration, cancellationToken)); }