public async Task <ResponseWithHeaders <AssetConversion, MixedRealityRemoteRenderingCreateConversionHeaders> > CreateConversionAsync(Guid accountId, string conversionId, CreateConversionSettings body, CancellationToken cancellationToken = default) { if (conversionId == null) { throw new ArgumentNullException(nameof(conversionId)); } if (body == null) { throw new ArgumentNullException(nameof(body)); } using var message = CreateCreateConversionRequest(accountId, conversionId, body); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new MixedRealityRemoteRenderingCreateConversionHeaders(message.Response); switch (message.Response.Status) { case 200: case 201: { AssetConversion value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = AssetConversion.DeserializeAssetConversion(document.RootElement); return(ResponseWithHeaders.FromValue(value, headers, message.Response)); }
internal HttpMessage CreateCreateConversionRequest(Guid accountId, string conversionId, CreateConversionSettings body) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Put; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); uri.AppendPath("/accounts/", false); uri.AppendPath(accountId, true); uri.AppendPath("/conversions/", false); uri.AppendPath(conversionId, true); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(body); request.Content = content; return(message); }