【问题标题】:InvalidXmlRequest error for Azure REST API requestAzure REST API 请求的 InvalidXmlRequest 错误
【发布时间】:2013-10-20 12:25:43
【问题描述】:

我正在使用 Azure REST API 创建一个 Azure 存储帐户,使用的文档位于:http://msdn.microsoft.com/en-us/library/hh264518.aspx

我不断收到代码 InvalidXmlRequest 的 400 错误(“请求正文的 XML 无效或未正确指定。”)。唯一相关的线程似乎在Management API - The request body XML was invalid or not correctly specified - 我已经尝试了我的请求的几种变体(例如删除 xml 标头,从正文中删除空元素等),但仍然看到相同的错误。

响应标头中也没有 requestId(使用 GET OperationStatus 获取更多信息)。

完整的 RAW 请求和响应(针对我的一项试验)如下。

关于我在这里缺少什么的任何想法?

请求:

POST https://management.core.windows.net/<mysubscriptionid>/services/storageservices HTTP/1.1
x-ms-version: 2011-06-01
Content-Type: application/xml
Host: management.core.windows.net
Content-Length: 350
Expect: 100-continue

<?xml version="1.0" encoding="utf-8"?><CreateStorageServiceInput xmlns="http://schemas.microsoft.com/windowsAzure"><ServiceName>gjhgkjhgkgk</ServiceName><Description /><Label>gjhgkjhgkgk</Label><AffinityGroup /><Location>North Central US</Location><GeoReplicationEnabled>true</GeoReplicationEnabled><ExtendedProperties /></CreateStorageServiceInput>

回复:

HTTP/1.1 400 Bad Request
Content-Length: 228
Content-Type: application/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Sun, 20 Oct 2013 02:33:08 GMT

<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>InvalidXmlRequest</Code><Message>The request body's XML was invalid or not correctly specified.</Message></Error>

【问题讨论】:

    标签: rest azure


    【解决方案1】:

    我注意到的两件事:

    需要标签。存储帐户的名称,指定为 base64 编码的字符串。名称最长可达 100 个字符。 该名称可用于标识您的跟踪的存储帐户 目的。

    • 与您的问题本身无关,但您正尝试在North Central US 区域中创建存储帐户。请注意,您无法在美国中北部和中南部地区创建新资源。

    【讨论】:

    • 我尝试使用 base64 编码标签和美国西部作为位置。这仍然给了我同样的错误:&lt;CreateStorageServiceInput xmlns="http://schemas.microsoft.com/windowsazure"&gt;&lt;ServiceName&gt;gjhgkjhgkgk&lt;/ServiceName&gt;&lt;Description /&gt;&lt;Label&gt;Z2poZ2tqaGdrZ2s=&lt;/Label&gt;&lt;AffinityGroup /&gt;&lt;Location&gt;West US&lt;/Location&gt;&lt;GeoReplicationEnabled&gt;true&lt;/GeoReplicationEnabled&gt;&lt;ExtendedProperties /&gt;&lt;/CreateStorageServiceInput&gt;
    • 尝试从您的请求中删除关联组节点。 HTH。
    • 是的,成功了。对我有用的请求是:&lt;CreateStorageServiceInput xmlns="http://schemas.microsoft.com/windowsazure"&gt;&lt;ServiceName&gt;gjhgkjhgkgk&lt;/ServiceName&gt;&lt;Description /&gt;&lt;Label&gt;Z2poZ2tqaGdrZ2s=&lt;/Label&gt;&lt;Location&gt;West US&lt;/Location&gt;&lt;GeoReplicationEnabled&gt;true&lt;/GeoReplicationEnabled&gt;&lt;ExtendedProperties /&gt;&lt;/CreateStorageServiceInput&gt; 谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-05-09
    • 2014-05-04
    • 2018-02-03
    • 1970-01-01
    • 2020-04-16
    • 1970-01-01
    • 2016-11-08
    • 1970-01-01
    相关资源
    最近更新 更多