Azure,BadRequest:请求的主体为空或没有预期的内容

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

最初是 错误。

然后我遇到了 错误。

现在我来了。

相同代码:

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"
    }
});

还有这个错误:

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

其他2个错误是有道理的,但这个似乎有点死胡同。

这次我做错了什么?

请更改您的代码并包含 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!
            }
        });

这应该可以解决问题。