Xamarin MonoAndroid Azure 移动服务 InsertAsync

2024-02-20

我正在使用 Xamarin for Android 并添加了 azure 移动服务组件。

我正在尝试创建待办事项列表应用程序,例如(https://github.com/xamarin/azure-mobile-services https://github.com/xamarin/azure-mobile-services)

我这样连接到移动服务:

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 Insert 函数将数据插入表中

   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,在调试时,当我挖掘 t.Exception 时,我发现Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException

如果需要的话,我很乐意提供其余的代码。

Edited我获得异常级别的唯一方法是在调试时从监视窗口获取详细信息。 异常有2个属性:Request&Response 请求: - 请求 {Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest} Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest 接受“application/json”字符串 内容 "{\"text\": \"tyu\", \"complete\": false}" 字符串 ContentType“application/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-ZUMO-INSTALLATION-ID”字符串 值“17b22eec-edd2-4a15-a37f-d4c5d87e4e8e”字符串 + 非公开会员
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair 键“X-ZUMO-APPLICATION”字符串 值“FmlVNVhdQhNEAIZZVptKhxlQNuJrlq37”字符串 + 非公开会员
+ 原始视图
方法“POST”字符串 - Uri {System.Uri} System.Uri 绝对路径“/.azure-mobile.net/tables/Item”字符串 绝对Uri 权限“ichange.azure-mobile.net”字符串 DnsSafeHost“ichange.azure-mobile.net”字符串 片段“”字符串 主机“ichange.azure-mobile.net”字符串 HostNameType System.UriHostNameType.Dns System.UriHostNameType IsAbsoluteUri true bool IsDefaultPort true bool IsFile false 布尔值 IsLoopback false bool IsUnc false 布尔值 LocalPath“/.azure-mobile.net/tables/Item”字符串 原始字符串
PathAndQuery“/.azure-mobile.net/tables/Item”字符串 端口 80 内部 请求参数 方案“http”字符串 + 段 {string[4]} string[] UserEscaped false 布尔值 用户信息“”字符串 + 静态成员
+ 非公开会员
静态成员

响应 - 响应 {Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse} Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse 内容 "{\"code\":404,\"error\":\"Error: Not Found\"}" 字符串 ContentType“application/json”字符串 - 标头计数=8 System.Collections.Generic.Dictionary - 项目 {System.Collections.Generic.KeyValuePair[8]} System.Collections.Generic.KeyValuePair[] - [0] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair 键“Cache-Control”字符串 值“无缓存”字符串 + 非公开会员
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair 键“内容长度”字符串 值“39”字符串 + 非公开会员
- [2] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair 键“内容类型”字符串 值“application/json”字符串 + 非公开会员
- [3] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair 键“服务器”字符串 值“Microsoft-IIS/8.0”字符串 + 非公开会员
- [4] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair 键“Set-Cookie”字符串 值“ARRAffinity=3041b7170f63e41156a1ff0b65518583e91f68d4f90a680a7750bd8d12f209e0;Path=/;Domain=ichange.a…”字符串 + 非公开会员
- [5] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair 键“x-zumo-version”字符串 值“Zumo.Main.0.1.6.3017.Runtime”字符串 + 非公开会员
- [6] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair 键“X-Powered-By”字符串 值“ASP.NET”字符串 + 非公开会员
- [7] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair 键“日期”字符串 值“2013 年 6 月 27 日星期四 18:23:56 GMT”字符串 + 非公开会员
+ 原始视图
ResponseStatus Microsoft.WindowsAzure.MobileServices.ServiceFilterResponseStatus.ProtocolError Microsoft.WindowsAzure.MobileServices.ServiceFilterResponseStatus 状态代码 404 整数 状态描述“未找到”字符串


正如我们在评论中讨论的:您传递给的 URLMobileServiceClient构造函数不正确。 “未找到”响应让我查看您拥有的 URL:

public static string mobileServiceUrl =
    "http://MyMoblieService.azure-mobile.net/.azure-mobile.net/";

这是不正确的。应该如下图所示:

public static string mobileServiceUrl =
    "http://MyMoblieService.azure-mobile.net/";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Xamarin MonoAndroid Azure 移动服务 InsertAsync 的相关文章

  • 在两个 .cpp 文件之间定义全局变量 [重复]

    这个问题在这里已经有答案了 如何在 A cpp 和 B cpp 之间共享 全球化 bool 变量 其中它们都不包含其他 h 文件 他们有其他联合头文件 但彼此没有 我可以在这些共享标头中定义全局变量吗 Thanks 我可以在这些共享标头中定
  • 在 Mono 上使用 Mono for android

    将 MonoDevelop 的编译器切换为 Mono 工具而不是 NET 看起来非常容易 您只需在 IDE 的设置下选择不同的框架即可 然而 在切换到 Mono 并使用 Mono 工具编译项目后 Mono for android 似乎不再是
  • 可选参数“必须是编译时常量”

    我有一个类分为两个部分文件 如下所示 public partial class PersonRepository BaseRepository
  • 浏览器收集哪些值作为回发数据?

    当页面被发送回服务器时 浏览器收集每个控件的当前值并将其粘贴到一个字符串中 然后 该回发数据通过 HTTP POST 发送回服务器 Q1 除了控件的 Text 属性和 SelectedIndexchanged 因此除了用户输入数据 之外 控
  • 如何检查 .NET 4.0 中的泛型参数是否是动态的

    我有课ObjectMapper
  • 使用 QSet 作为 Qt 地图容器中的键

    我需要一个映射 其中键是唯一的 并且每个键都是一组或自定义 POD 结构 其中包含 3 个数据项 这些值只是指向对象实例的指针 从阅读Qt 的 QMap 与 QHash 的文档 http qt project org doc qt 4 8
  • 将语句插入 SQL Server 数据库

    最近几天我试图找到这个错误 但没有成功 我正在尝试在数据库中插入一个新行 一切都很顺利 没有错误 也没有程序崩溃 My INSERT声明如下 INSERT INTO Polozaj Znesek Uporabnik Cas Kupec Po
  • 不支持使用 JDK 版本“11.0.1”进行构建。请安装 JDK 版本 `1.8.0`

    我已经下载了 Visual Studio for Mac 并尝试开始学习 Xamarin iOS 和 Android 问题是当我尝试运行 android 项目时出现以下错误 Building with JDK Version 11 0 1
  • 如何在 C++ 的子目录中创建文件?

    这是我的代码 如何在子目录联系人中创建文件 每次创建该文件时 它都会出现在与我的程序相同的目录中 int main ofstream myfile contacts myfile open a myfile close 在构造函数中指定完整
  • 基于 C++ 范围的 for 循环

    尝试使用基于范围的 for 循环执行某些操作 可以使用常规的 for 循环来完成 如下所示 vector
  • 使用对象列表构建树

    我有一个带有属性 id 和parent id 的对象列表 我想建造一棵树来连接那些孩子和父母 1 个父对象可以有多个子对象 并且有一个对象将成为所有对象的祖先 实现该功能最快的算法是什么 我使用 C 作为编程语言 但其他语言也可以 像这样的
  • Active Directory B2C 身份验证以及在数据库中创建/存储用户 ID

    我正在制作一个移动应用程序 并希望使用 AD B2C 内容来处理用户的身份验证 我需要将它们的数据存储在 SQL DB 中 该数据库也位于 Azure 上 我打算让我的应用程序使用 REST 与我要编写的一些函数进行通信 然后与数据库后端进
  • ASP.NET Web API Swagger(Swashbuckle)重复OperationId

    I have a web api controller like below In swagger output I am having the below image And when I want to consume it in my
  • C# - 命名空间内的类型声明

    在命名空间内而不是在类中声明类型的可能用途是什么 For ex namespace Test public delegate void Ispossible 这是有效的并且不会产生任何编译错误 但我无法想象为什么我们会以这种方式声明它而不是
  • 如何使用eclipse构建C++应用程序

    我已经从以下位置下载了 Eclipse Juno for C here http www eclipse org downloads download php file technology epp downloads release ju
  • printf 参数不足

    我的问题是关于缺少参数的 printf 之后的行为 printf s blah blah d int integer was given as argument and not int written 我已经知道 如果格式参数不足 则行为是
  • 统一;随机物体移动[关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我正在制作一款机器人战斗游戏 我希望敌人随机移动 然后有时会向敌人移动 我希望运动包含在其中的代码 else if avoid fal
  • Crypto++ 和压缩 EC 密钥

    如何在 Crypto 中生成压缩的 ECDSA 密钥 AutoSeededRandomPool prng ECDSA
  • 计算两个日期之间的工作日数?

    在C 中 如何计算business 或工作日 两个日期之间的天数 我以前曾经遇到过这样的任务 并且我已经找到了解决方案 当可以避免的时候 我会避免列举其间的所有日子 这里就是这种情况 正如我在上面的一个答案中看到的那样 我什至没有提到创建一
  • 如何设置 Swashbuckle 与 Microsoft.AspNetCore.Mvc.Versioning

    我们有asp net core webapi 我们添加了Microsoft AspNetCore Mvc Versioning and Swashbuckle拥有招摇的用户界面 我们将控制器指定为 ApiVersion 1 0 Route

随机推荐