/// <summary>
        /// Puts the specified EntityType3 reference and returns <see cref="GraphResponse"/> object.
        /// </summary>
        /// <param name="id">The EntityType3 reference to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The task to await of <see cref="GraphResponse"/>.</returns>
        public System.Threading.Tasks.Task <GraphResponse> PutResponseAsync(string id, CancellationToken cancellationToken = default)
        {
            this.Method      = HttpMethods.PUT;
            this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
            var referenceRequestBody = new ReferenceRequestBody()
            {
                ODataId = string.Format(@"{0}/users/{1}", this.Client.BaseUrl, id)
            };

            return(this.SendAsyncWithGraphResponse(referenceRequestBody, cancellationToken));
        }
Beispiel #2
0
        /// <summary>
        /// Adds the specified DirectoryObject to the collection via POST.
        /// </summary>
        /// <param name="directoryObject">The DirectoryObject to add.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The task to await.</returns>
        public System.Threading.Tasks.Task AddAsync(DirectoryObject directoryObject, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

            if (string.IsNullOrEmpty(directoryObject.Id))
            {
                throw new ServiceException(new Error {
                    Code = "invalidRequest", Message = "ID is required to add a reference."
                });
            }

            var requestBody = new ReferenceRequestBody {
                ODataId = string.Format("{0}/directoryObjects/{1}", this.Client.BaseUrl, directoryObject.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }
        /// <summary>
        /// Adds the specified WindowsInformationProtectionDeviceRegistration to the collection via POST.
        /// </summary>
        /// <param name="windowsInformationProtectionDeviceRegistration">The WindowsInformationProtectionDeviceRegistration to add.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The task to await.</returns>
        public System.Threading.Tasks.Task AddAsync(WindowsInformationProtectionDeviceRegistration windowsInformationProtectionDeviceRegistration, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

            if (string.IsNullOrEmpty(windowsInformationProtectionDeviceRegistration.Id))
            {
                throw new ServiceException(new Error {
                    Code = "invalidRequest", Message = "ID is required to add a reference."
                });
            }

            var requestBody = new ReferenceRequestBody {
                ODataId = string.Format("{0}/deviceAppManagement/windowsInformationProtectionDeviceRegistrations/{1}", this.Client.BaseUrl, windowsInformationProtectionDeviceRegistration.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }