任何帮助,非常感谢。
我正在使用适用于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>
答案 0 :(得分:1)
网址看起来不对,但我不确定它是如何形成的......通常应该是https://<account>.table.core.windows.net/<table>(PartitionKey='<pkey>',RowKey='<rkey>')
。但我没有解释为什么你的看起来不正确。 (代码看起来相当简单。)
您是否能够执行其他操作,例如插入?当你这样做时,网址在Fiddler中是否正确?