From 7d9d3efd2edef2033490084c9e19c16af4fc3142 Mon Sep 17 00:00:00 2001 From: magodo Date: Tue, 25 Jan 2022 15:41:52 +0800 Subject: [PATCH] Table exists API add api version and accept json 1. API version is necessary here to make the API accepts the AAD Auth 2. The Accept json header is necessary here since otherwise the returned xml is in atom format, in which case the autorest will fail to parse. --- storage/2020-08-04/table/tables/exists.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/storage/2020-08-04/table/tables/exists.go b/storage/2020-08-04/table/tables/exists.go index b3a2718..6abe4f0 100644 --- a/storage/2020-08-04/table/tables/exists.go +++ b/storage/2020-08-04/table/tables/exists.go @@ -47,15 +47,21 @@ func (client Client) ExistsPreparer(ctx context.Context, accountName, tableName "tableName": autorest.Encode("path", tableName), } + headers := map[string]interface{}{ + "x-ms-version": APIVersion, + "Accept": "application/json;odata=nometadata", + } + // NOTE: whilst the API documentation says that API Version is Optional // apparently specifying it causes an "invalid content type" to always be returned // as such we omit it here :shrug: preparer := autorest.CreatePreparer( autorest.AsGet(), - autorest.AsContentType("application/xml"), + autorest.AsContentType("application/json"), autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/Tables('{tableName}')", pathParameters)) + autorest.WithPathParameters("/Tables('{tableName}')", pathParameters), + autorest.WithHeaders(headers)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) }