Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "BadRequest" issue with WebApps InstallSiteExtensions #241

Open
Denifia opened this issue Mar 28, 2018 · 3 comments
Open

Fix "BadRequest" issue with WebApps InstallSiteExtensions #241

Denifia opened this issue Mar 28, 2018 · 3 comments
Assignees

Comments

@Denifia
Copy link

Denifia commented Mar 28, 2018

When adding a site extension to a web app using the following code, I receive a CloudException "Operation returned an invalid status code 'BadRequest'".

Azure
  .Configure()
  .Authenticate(credentials)
  .WithSubscription("SubscriptionId")
  .WebApps
  .Inner
  .InstallSiteExtensionAsync("ResourceGroupName", "WebAppName", "ExtensionName");

After investigation, I found that the underlying Microsoft.Azure.Management.AppService.Fluent.WebAppsOperations.BeginInstallSiteExtensionWithHttpMessagesAsync method sends no Content in its _httpRequest. Changing the auto generated code to send an empty object fixed the issue.

public async Task<AzureOperationResponse<SiteExtensionInfoInner>> BeginInstallSiteExtensionWithHttpMessagesAsync(string resourceGroupName, string name, string siteExtensionId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
    ...

    // Serialize Request
    string _requestContent = null;

    // Added the following 3 lines
    _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(new object(), Client.SerializationSettings);
    _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
    _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");

    ...
}

I haven't looked into why the AutoRest Code Generator is creating this code.

@vludax
Copy link

vludax commented Apr 4, 2018

Having the same problem with this SDK: https://github.com/Azure/azure-sdk-for-net/
Should we log a separate issue there?

@hovsepm
Copy link
Contributor

hovsepm commented Apr 4, 2018

@vludax the issue seems to be on a server side/bad server spec here https://github.com/Azure/azure-rest-api-specs/tree/master/specification/web/resource-manager. I'd recommend opening an issue in the specs repo first.

@thecodetinker
Copy link

I've just hit this as well, still not fixed 5 years later :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants