Xamarin MonoAndroid的Azure移动服务InsertAsync [英] Xamarin MonoAndroid Azure mobile service InsertAsync
问题描述
我使用Xamarin Android和添加了天蓝色的移动服务componenet。
I'm using Xamarin for Android and have added the azure mobile services componenet.
我想创建( https://github.com/的待办事项列表应用xamarin / Azure的移动服务)
我连接到这样的移动服务:
I connect to the mobile service like this:
public static string mobileServiceUrl = "http://MyMoblieService.azure-mobile.net/.azure-mobile.net/";
public static string mobileServiceAppKey = "MyAppKey";
private static readonly MobileServiceClient MobileService =
new MobileServiceClient(mobileServiceUrl, mobileServiceAppKey);
this.adapter = new TodoAdapter(MobileService.GetTable<Item>(), this);
我用的是adapte插入功能将数据插入到表
I use the adapte Insert function to insert data into the table
public void Insert(Item item)
{
IsUpdating = true;
this.items.Add(item);
NotifyDataSetChanged();
this.table.InsertAsync(item).ContinueWith(t =>
{
if (t.IsFaulted)
{
this.items.Remove(item);
NotifyDataSetChanged();
}
IsUpdating = false;
}, scheduler);
}
和每次我得到 t.IsFaulted = TRUE
,而debuging当我t.Exception挖我找到 Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException
and everytime I get t.IsFaulted = true
, while debuging when I dig in t.Exception I find Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException
如果需要的话我会很乐意提供code的其余部分。
I would be glad to supply the rest of the code if needed.
编辑
我能得到的异常水平的唯一方法是通过监视窗口获取详细信息,同时调试。
唯一的例外有2个属性:请求和放大器;响应
请求:
- 请求{} Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest
接受应用程序/ JSON串
内容{\\文本\\:\\TYU \\,\\完整\\:虚假}字符串
ContentType的应用/ JSON串
- 头数= 2 System.Collections.Generic.Dictionary
- 物品{System.Collections.Generic.KeyValuePair [2]} System.Collections.Generic.KeyValuePair []
- [0] {} System.Collections.Generic.KeyValuePair System.Collections.Generic.KeyValuePair
关键的X-谟安装-ID的字符串
值17b22eec-edd2-4a15-a37f-d4c5d87e4e8e字符串
+非公共成员结果
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
关键的X-谟 - 应用的字符串
值FmlVNVhdQhNEAIZZVptKhxlQNuJrlq37字符串
+非公共成员结果
+ RAW查看结果
方法POST字符串
- 乌里{}的System.Uri的System.Uri
AbsolutePath/.azure-mobile.net/tables/Item字符串
绝对URI
管理局ichange.azure-mobile.net字符串
DnsSafeHostichange.azure-mobile.net字符串
片段,串
举办ichange.azure-mobile.net字符串
HostNameType System.UriHostNameType.Dns System.UriHostNameType
IsAbsoluteUri真布尔
IsDefaultPort真布尔
ISFILE假布尔
IsLoopback假布尔
IsUnc假布尔
localPath来/.azure-mobile.net/tables/Item字符串
OriginalString结果
PathAndQuery/.azure-mobile.net/tables/Item字符串
端口80 INT
查询串
计划HTTP字符串
+ {分段串[4]}的String []
UserEscaped假布尔
的UserInfo,串
+静态成员
+非公共成员结果
静态成员
Edited
The only way I could get the exception level is by getting the details from the watch window while debugging.
The exception has 2 attributes: Request&Response
The request:
- Request {Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest} Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest
Accept "application/json" string
Content "{\"text\": \"tyu\", \"complete\": false}" string
ContentType "application/json" string
- Headers Count=2 System.Collections.Generic.Dictionary
- Items {System.Collections.Generic.KeyValuePair[2]} System.Collections.Generic.KeyValuePair[]
- [0] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "X-ZUMO-INSTALLATION-ID" string
Value "17b22eec-edd2-4a15-a37f-d4c5d87e4e8e" string
+ Non-public members
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "X-ZUMO-APPLICATION" string
Value "FmlVNVhdQhNEAIZZVptKhxlQNuJrlq37" string
+ Non-public members
+ Raw View
Method "POST" string
- Uri {System.Uri} System.Uri
AbsolutePath "/.azure-mobile.net/tables/Item" string
AbsoluteUri
Authority "ichange.azure-mobile.net" string
DnsSafeHost "ichange.azure-mobile.net" string
Fragment "" string
Host "ichange.azure-mobile.net" string
HostNameType System.UriHostNameType.Dns System.UriHostNameType
IsAbsoluteUri true bool
IsDefaultPort true bool
IsFile false bool
IsLoopback false bool
IsUnc false bool
LocalPath "/.azure-mobile.net/tables/Item" string
OriginalString
PathAndQuery "/.azure-mobile.net/tables/Item" string
Port 80 int
Query "" string
Scheme "http" string
+ Segments {string[4]} string[]
UserEscaped false bool
UserInfo "" string
+ Static members
+ Non-public members
Static members
的响应
- 响应{} Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse
内容{\\code \\:404,\\错误\\:\\错误:未找到\\}字符串
ContentType的应用/ JSON串
- 头数= 8 System.Collections.Generic.Dictionary
- 物品{System.Collections.Generic.KeyValuePair [8]} System.Collections.Generic.KeyValuePair []
- [0] {} System.Collections.Generic.KeyValuePair System.Collections.Generic.KeyValuePair
关键的缓存控制的字符串
值no-cache的字符串
+非公共成员结果
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
关键的内容长度的字符串
值39字符串
+非公共成员结果
- [2] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
关键的内容类型的字符串
值应用/ JSON串
+非公共成员结果
- [3] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
关键的服务器字符串
值微软-IIS / 8.0的字符串
+非公共成员结果
- [4] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
密钥设置Cookie的字符串
值\"ARRAffinity=3041b7170f63e41156a1ff0b65518583e91f68d4f90a680a7750bd8d12f209e0;Path=/;Domain=ichange.a…\"串
+非公共成员结果
- [5] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
关键的X-谟版串
值Zumo.Main.0.1.6.3017.Runtime字符串
+非公共成员结果
- [6] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键X供电,通过串
值ASP.NET字符串
+非公共成员结果
- [7] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
关键的日期字符串
值星期四,2013年6月27日18时23分56秒GMT字符串
+非公共成员结果
+ RAW查看结果
ResponseStatus Microsoft.WindowsAzure.MobileServices.ServiceFilterResponseStatus.ProtocolError Microsoft.WindowsAzure.MobileServices.ServiceFilterResponseStatus
状态code 404 INT
状态说明未找到字符串
The response
- Response {Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse} Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse
Content "{\"code\":404,\"error\":\"Error: Not Found\"}" string
ContentType "application/json" string
- Headers Count=8 System.Collections.Generic.Dictionary
- Items {System.Collections.Generic.KeyValuePair[8]} System.Collections.Generic.KeyValuePair[]
- [0] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "Cache-Control" string
Value "no-cache" string
+ Non-public members
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "Content-Length" string
Value "39" string
+ Non-public members
- [2] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "Content-Type" string
Value "application/json" string
+ Non-public members
- [3] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "Server" string
Value "Microsoft-IIS/8.0" string
+ Non-public members
- [4] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "Set-Cookie" string
Value "ARRAffinity=3041b7170f63e41156a1ff0b65518583e91f68d4f90a680a7750bd8d12f209e0;Path=/;Domain=ichange.a…" string
+ Non-public members
- [5] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "x-zumo-version" string
Value "Zumo.Main.0.1.6.3017.Runtime" string
+ Non-public members
- [6] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "X-Powered-By" string
Value "ASP.NET" string
+ Non-public members
- [7] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
Key "Date" string
Value "Thu, 27 Jun 2013 18:23:56 GMT" string
+ Non-public members
+ Raw View
ResponseStatus Microsoft.WindowsAzure.MobileServices.ServiceFilterResponseStatus.ProtocolError Microsoft.WindowsAzure.MobileServices.ServiceFilterResponseStatus
StatusCode 404 int
StatusDescription "Not Found" string
推荐答案
正如我们在讨论的意见:你传递给 MobileServiceClient
构造函数中的URL不正确。在未找到的反应让我看在你拥有的网址:
As we discussed in the comments: the URL you're passing to the MobileServiceClient
constructor is incorrect. The 'Not Found' response made me look in the URL which you have:
public static string mobileServiceUrl =
"http://MyMoblieService.azure-mobile.net/.azure-mobile.net/";
这就是不正确。它应该如图6-8所示:
And that's incorrect. It should be as shown below:
public static string mobileServiceUrl =
"http://MyMoblieService.azure-mobile.net/";
这篇关于Xamarin MonoAndroid的Azure移动服务InsertAsync的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!