From ee4404c439efa3e5d97e0c3e61675d5017959f6c Mon Sep 17 00:00:00 2001 From: victor-meng <56978073+victor-meng@users.noreply.github.com> Date: Mon, 2 Aug 2021 19:11:42 -0700 Subject: [PATCH] Fix enable synapse link error (#918) * Fix enable synapse error * Default all ARM requests to JSON Co-authored-by: Steve Faulkner --- src/Utils/arm/generatedClients/cosmos/databaseAccounts.ts | 8 +++++++- src/Utils/arm/request.ts | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Utils/arm/generatedClients/cosmos/databaseAccounts.ts b/src/Utils/arm/generatedClients/cosmos/databaseAccounts.ts index 87b00b24b..5c52c7d61 100644 --- a/src/Utils/arm/generatedClients/cosmos/databaseAccounts.ts +++ b/src/Utils/arm/generatedClients/cosmos/databaseAccounts.ts @@ -29,7 +29,13 @@ export async function update( body: Types.DatabaseAccountUpdateParameters ): Promise { const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`; - return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PATCH", apiVersion, body }); + return armRequest({ + host: configContext.ARM_ENDPOINT, + path, + method: "PATCH", + apiVersion, + body, + }); } /* Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account. */ diff --git a/src/Utils/arm/request.ts b/src/Utils/arm/request.ts index e593633ac..69391201b 100644 --- a/src/Utils/arm/request.ts +++ b/src/Utils/arm/request.ts @@ -6,6 +6,7 @@ Instead, generate ARM clients that consume this function with stricter typing. */ import promiseRetry, { AbortError } from "p-retry"; +import { HttpHeaders } from "../../Common/Constants"; import { configContext } from "../../ConfigContext"; import { userContext } from "../../UserContext"; @@ -45,6 +46,7 @@ interface Options { method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD"; body?: unknown; queryParams?: ARMQueryParams; + contentType?: string; } export async function armRequestWithoutPolling({ @@ -54,6 +56,7 @@ export async function armRequestWithoutPolling({ method, body: requestBody, queryParams, + contentType, }: Options): Promise<{ result: T; operationStatusUrl: string }> { const url = new URL(path, host); url.searchParams.append("api-version", configContext.armAPIVersion || apiVersion); @@ -70,6 +73,7 @@ export async function armRequestWithoutPolling({ method, headers: { Authorization: userContext.authorizationToken, + [HttpHeaders.contentType]: contentType || "application/json", }, body: requestBody ? JSON.stringify(requestBody) : undefined, }); @@ -104,6 +108,7 @@ export async function armRequest({ method, body: requestBody, queryParams, + contentType, }: Options): Promise { const armRequestResult = await armRequestWithoutPolling({ host, @@ -112,6 +117,7 @@ export async function armRequest({ method, body: requestBody, queryParams, + contentType, }); const operationStatusUrl = armRequestResult.operationStatusUrl; if (operationStatusUrl) {