0

任何帮助,非常感谢。

我正在为 Azure 存储表使用 1.6 SDK。在 UpdateObject() 我收到以下错误:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code>InvalidInput</code>
  <message xml:lang="en-US">One of the request inputs is not valid.
RequestId:b78bc343-f93c-4ec7-8991-24386131de43
Time:2012-08-08T01:25:32.4366914Z</message>
</error>

这是请求(来自 Fiddler):

MERGE https://foo.table.core.windows.net/foo('87a23657-9206-4450-a7ca-09d599b41b9f') HTTP/1.1
User-Agent: Microsoft ADO.NET Data Services
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 2.0;NetFx
x-ms-version: 2011-08-18
x-ms-date: Wed, 08 Aug 2012 01:24:56 GMT
Authorization: SharedKeyLite <foo>
Accept: application/atom+xml,application/xml
Accept-Charset: UTF-8
Content-Type: application/atom+xml
If-Match: *
Host: foo.table.core.windows.net
Content-Length: 1047

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title />
  <author>
    <name />
  </author>
  <updated>2012-08-08T01:24:56.9434703Z</updated>
  <id>https://foo.table.core.windows.net/foo('87a23657-9206-4450-a7ca-09d599b41b9f')</id>
  <content type="application/xml">
    <m:properties>
      <d:EmailAddress>foo</d:EmailAddress>
      <d:Enabled m:type="Edm.Boolean">false</d:Enabled>
      <d:Id>87a23657-9206-4450-a7ca-09d599b41b9f</d:Id>
      <d:LastSignIn m:null="true" />
      <d:Name>new</d:Name>
      <d:PIN>0000</d:PIN>
      <d:PartitionKey>sandbox</d:PartitionKey>
      <d:RowKey>87a23657-9206-4450-a7ca-09d599b41b9f</d:RowKey>
      <d:SignupDate m:null="true" />
      <d:Timestamp m:type="Edm.DateTime">0001-01-01T00:00:00</d:Timestamp>
    </m:properties>
  </content>
</entry>

这是对 UpdateObject() 的调用:

Public Sub Update(existingItem As UserDataModel)
    _ServiceContext.AttachTo(UserDataServiceContext.UserTableName, existingItem, "*")
    _ServiceContext.UpdateObject(existingItem)
    _ServiceContext.SaveChanges()
End Sub

下面是初始化服务上下文的代码:

Public Sub New()
    Try
        Dim storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString")
        _ServiceContext = New UserDataServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials)
        _ServiceContext.IgnoreResourceNotFoundException = True
        ' Create the tables
        ' In this case, just a single table.  
        storageAccount.CreateCloudTableClient().CreateTableIfNotExist(UserDataServiceContext.UserTableName)
    Catch ex As Exception
        Debug.WriteLine("Problem with New() UserDataSource. Error: " & ex.Message)
    End Try
End Sub

如果还有什么我可以提供的,请告诉我...

干杯,

托马斯

编辑 1:这是 Fiddler 中成功插入的样子:

POST https://foo.table.core.windows.net/<tablename> HTTP/1.1
User-Agent: Microsoft ADO.NET Data Services
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 2.0;NetFx
x-ms-version: 2011-08-18
x-ms-date: Wed, 08 Aug 2012 15:41:36 GMT
Authorization: SharedKeyLite <key>
Accept: application/atom+xml,application/xml
Accept-Charset: UTF-8
Content-Type: application/atom+xml
Host: <tablename>.table.core.windows.net
Content-Length: 990

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title />
  <author>
    <name />
  </author>
  <updated>2012-08-08T15:41:36.3923506Z</updated>
  <id />
  <content type="application/xml">
    <m:properties>
      <d:EmailAddress>foo@gmail.com</d:EmailAddress>
      <d:Enabled m:type="Edm.Boolean">false</d:Enabled>
      <d:Id>74cdf74d-4eea-40b8-93c4-a7f8bc01c387</d:Id>
      <d:LastSignIn>634800372963013454</d:LastSignIn>
      <d:Name>(test)</d:Name>
      <d:PIN>0000</d:PIN>
      <d:PartitionKey>sandbox</d:PartitionKey>
      <d:RowKey>74cdf74d-4eea-40b8-93c4-a7f8bc01c387</d:RowKey>
      <d:SignupDate>634800372963013454</d:SignupDate>
      <d:Timestamp m:type="Edm.DateTime">0001-01-01T00:00:00</d:Timestamp>
    </m:properties>
  </content>
</entry>
4

1 回答 1

1

The URL looks wrong, but I'm not sure how it got that way... it should normally be something like https://<account>.table.core.windows.net/<table>(PartitionKey='<pkey>',RowKey='<rkey>'). But I have no explanation for why yours doesn't look right. (The code looks fairly straightforward.)

Are you able to perform other operations, like an insert? Do the URLs look right in Fiddler when you do that?

于 2012-08-08T04:37:02.520 回答