Management API - 创建VM - InvalidXmlRequest - 请求正文XML无效或未正确指定

时间:2014-04-10 18:46:06

标签: rest azure virtual-machine

从Azure REST管理API创建虚拟机时出错。有人可以指出我在下面的XML中发布了什么错误

错误--- <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>

我的帖子字符串:

"  <Deployment xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">" + 
"    <Name>SomeName</Name>" + 
"    <DeploymentSlot>Production</DeploymentSlot>" + 
"    <Label>SomeLabel</Label>" + 
"    <RoleList>" + 
"      <Role>" + 
"        <RoleName>SomeRoleName</RoleName>" + 
"        <RoleType>PersistentVMRole</RoleType>" + 
"        <ConfigurationSets>" + 
"          <ConfigurationSet i:type=\"WindowsProvisioningConfigurationSet\">" + 
"            <ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType>" + 
"            <ComputerName>SomeCompName</ComputerName>" + 
"            <AdminPassword>Admin098</AdminPassword>" + 
"            <EnableAutomaticUpdates>true</EnableAutomaticUpdates>" + 
"            <ResetPasswordOnFirstLogon>false</ResetPasswordOnFirstLogon>" + 
"          </ConfigurationSet>" + 
"          <ConfigurationSet i:type=\"NetworkConfigurationSet\">" + 
"            <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>" + 
"            <InputEndpoints>" + 
"              <InputEndpoint>" + 
"                <LocalPort>3389</LocalPort>" + 
"                <Name>RemoteDesktop</Name>" + 
"                <Protocol>tcp</Protocol>" + 
"              </InputEndpoint>" + 
"            </InputEndpoints>" + 
"          </ConfigurationSet>" + 
"        </ConfigurationSets>" + 
"        <OSVirtualHardDisk>" + 
"          <DiskName>SomeDiskName-0-20121007173943</DiskName>" + 
"          <MediaLink>http://portalvhdsrx7q659n2n5j2.blob.core.windows.net/public/myvhd0008980.vhd</MediaLink>" + 
"          <SourceImageName>MSFT__Win2K8R2SP1-Datacenter-201208.01-en.us-30GB.vhd</SourceImageName>" + 
"        </OSVirtualHardDisk>" + 
"        <RoleSize>Small</RoleSize>" + 
"      </Role>" + 
"    </RoleList>" + 
"  </Deployment>"

您好, 还添加了AdminUsername。但仍然得到错误。 DateTime of request - 04-11 17:30:03.759

<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>

POST字符串

<Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">    <Name>SomeName</Name>    <DeploymentSlot>Production</DeploymentSlot>    <Label>SomeLabel</Label>    <RoleList>      <Role>        <RoleName>SomeRoleName</RoleName>        <RoleType>PersistentVMRole</RoleType>        <ConfigurationSets>          <ConfigurationSet i:type="WindowsProvisioningConfigurationSet">            <ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType>            <ComputerName>SomeCompName</ComputerName>            <AdminPassword>Admin098</AdminPassword>            <AdminUsername>AwesomeAdmin</AdminUsername>            <EnableAutomaticUpdates>true</EnableAutomaticUpdates>            <ResetPasswordOnFirstLogon>false</ResetPasswordOnFirstLogon>          </ConfigurationSet>          <ConfigurationSet i:type="NetworkConfigurationSet">            <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>            <InputEndpoints>              <InputEndpoint>                <LocalPort>3389</LocalPort>                <Name>RemoteDesktop</Name>                <Protocol>tcp</Protocol>              </InputEndpoint>            </InputEndpoints>          </ConfigurationSet>        </ConfigurationSets>        <OSVirtualHardDisk>          <DiskName>SomeDiskName-0-20121007173943</DiskName>          <MediaLink>http://portalvhdsrx7q659n2n5j2.blob.core.windows.net/public/myvhd0008980.vhd</MediaLink>          <SourceImageName>MSFT__Win2K8R2SP1-Datacenter-201208.01-en.us-30GB.vhd</SourceImageName>        </OSVirtualHardDisk>        <RoleSize>Small</RoleSize>      </Role>    </RoleList>  </Deployment>

1 个答案:

答案 0 :(得分:1)

尝试在AdminUsername节点之后添加AdminPassword节点。

"  <Deployment xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">" + 
"    <Name>SomeName</Name>" + 
"    <DeploymentSlot>Production</DeploymentSlot>" + 
"    <Label>SomeLabel</Label>" + 
"    <RoleList>" + 
"      <Role>" + 
"        <RoleName>SomeRoleName</RoleName>" + 
"        <RoleType>PersistentVMRole</RoleType>" + 
"        <ConfigurationSets>" + 
"          <ConfigurationSet i:type=\"WindowsProvisioningConfigurationSet\">" + 
"            <ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType>" + 
"            <ComputerName>SomeCompName</ComputerName>" + 
"            <AdminPassword>Admin098</AdminPassword>" + 
"            <AdminUsername>AwesomeAdmin</AdminUsername>" + 
"            <EnableAutomaticUpdates>true</EnableAutomaticUpdates>" + 
"            <ResetPasswordOnFirstLogon>false</ResetPasswordOnFirstLogon>" + 
"          </ConfigurationSet>" + 
"          <ConfigurationSet i:type=\"NetworkConfigurationSet\">" + 
"            <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>" + 
"            <InputEndpoints>" + 
"              <InputEndpoint>" + 
"                <LocalPort>3389</LocalPort>" + 
"                <Name>RemoteDesktop</Name>" + 
"                <Protocol>tcp</Protocol>" + 
"              </InputEndpoint>" + 
"            </InputEndpoints>" + 
"          </ConfigurationSet>" + 
"        </ConfigurationSets>" + 
"        <OSVirtualHardDisk>" + 
"          <DiskName>SomeDiskName-0-20121007173943</DiskName>" + 
"          <MediaLink>http://portalvhdsrx7q659n2n5j2.blob.core.windows.net/public/myvhd0008980.vhd</MediaLink>" + 
"          <SourceImageName>MSFT__Win2K8R2SP1-Datacenter-201208.01-en.us-30GB.vhd</SourceImageName>" + 
"        </OSVirtualHardDisk>" + 
"        <RoleSize>Small</RoleSize>" + 
"      </Role>" + 
"    </RoleList>" + 
"  </Deployment>"