Azure, BadRequest: The body of the request is empty or does not have the expected content

爱⌒轻易说出口 提交于 2019-12-12 03:57:16

问题


This started out as a SubscriptionNotFound error.

Then I ended up with a MissingRegistrationForLocation error.

And now I'm here.

Same code:

var dnsClient = new DnsManagementClient(new Microsoft.Azure.TokenCloudCredentials(result.AccessToken));

var zone = dnsClient.Zones.CreateOrUpdate("someresourcegroup", "mydomain.com", new Microsoft.Azure.Management.Dns.Models.ZoneCreateOrUpdateParameters {
    IfNoneMatch = "*",
    Zone = new Microsoft.Azure.Management.Dns.Models.Zone {
        Name = "mydomain.com",
        Location = "global"
    }
});

And this bug:

BadRequest: The body of the request is empty or does not have the expected content.

The other 2 errors makes sense, but this one seems a bit like a dead-end.

What Am I doing wrong this time around?


回答1:


Please change your code and include Properties:

        var zone = dnsClient.Zones.CreateOrUpdate("someresourcegroup", "mydomain.com", new Microsoft.Azure.Management.Dns.Models.ZoneCreateOrUpdateParameters
        {
            IfNoneMatch = "*",
            Zone = new Microsoft.Azure.Management.Dns.Models.Zone
            {
                Name = "mydomain.com",
                Location = "global",
                Properties = new ZoneProperties()//Add this line!
            }
        });

That should take care of the problem.



来源:https://stackoverflow.com/questions/35081852/azure-badrequest-the-body-of-the-request-is-empty-or-does-not-have-the-expecte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!