/// <summary>
        /// Creates a new devices batch along with the devices.
        /// </summary>
        /// <param name="newEntity">The new devices batch.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>The location to track the status of the create.</returns>
        public async Task <string> CreateAsync(DeviceBatchCreationRequest newEntity, CancellationToken cancellationToken = default)
        {
            newEntity.AssertNotNull(nameof(newEntity));

            return(await Partner.ServiceClient.PostAsync <DeviceBatchCreationRequest, string>(
                       new Uri(
                           string.Format(
                               CultureInfo.InvariantCulture,
                               $"/{PartnerService.Instance.ApiVersion}/{PartnerService.Instance.Configuration.Apis.CreateDeviceBatch.Path}",
                               Context),
                           UriKind.Relative),
                       newEntity,
                       cancellationToken).ConfigureAwait(false));
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new devices batch along with the devices.
        /// </summary>
        /// <param name="newEntity">The new devices batch.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>The location to track the status of the create.</returns>
        public async Task <string> CreateAsync(DeviceBatchCreationRequest newEntity, CancellationToken cancellationToken = default)
        {
            newEntity.AssertNotNull(nameof(newEntity));

            HttpResponseMessage response = await Partner.ServiceClient.PostAsync <DeviceBatchCreationRequest, HttpResponseMessage>(
                new Uri(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        $"/{PartnerService.Instance.ApiVersion}/{PartnerService.Instance.Configuration.Apis.CreateDeviceBatch.Path}",
                        Context),
                    UriKind.Relative),
                newEntity,
                cancellationToken).ConfigureAwait(false);

            return(response.Headers.Location != null?response.Headers.Location.ToString() : string.Empty);
        }