Мобильная служба Xamarin MonoAndroid Azure InsertAsync

Я использую Xamarin для Android и добавил компонент мобильных служб Azure.

Я пытаюсь создать приложение со списком задач, например (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

При необходимости я с радостью предоставлю остальной код.

Отредактировано. Единственный способ получить уровень исключения - это получить сведения из окна просмотра во время отладки. Исключение имеет 2 атрибута: Запрос и ответ Запрос: - Запрос {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" строка + Non-Public члены
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair Key "X-ZUMO-APPLICATION" строка Значение "FmlVNVhdQhNEAIZZVptKhxlQNuJrlq37" строка + R aw View
Метод "POST" строка - Uri {System.Uri} System.Uri AbsolutePath "/.azure-mobile.net/tables/Item" строка AbsoluteUri Authority "ichange.azure-mobile.net" строка 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 IsUnath" false bool "false bool IsUnath" false bool .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 "" строка + Статические члены
+ Непубличные члены < br> Статические члены

Ответ - Response {Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse} Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse Content "{\" code \ ": 404, \" error \ ": \" Error: Not Found \ "}" string ContentType " application / json "строка - Количество заголовков = 8 System.Collections.Generic.Dictionary - Items {System.Collections.Generic.KeyValuePair [8]} System.Collections.Generic.KeyValuePair [] - [0] {System.Collections.Generic .KeyValuePair} System.Collections.Generic.KeyValuePair Ключ "Cache-Control" строка Значение "no-cache" строка + Непубличные члены
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic .KeyValuePair Ключ "Content-Length" string Value "39" string + непубличные члены
- [2] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair Key "Content-Type" string Value "приложение / jso n "строка + непубличные члены
- [3] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair Key" Server "string Value" Microsoft-IIS / 8.0 "string + непубличные члены
- [4] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair Key "Set-Cookie" string Value "ARRAffinity = 3041b7170f63e41156a1ff0b65518583e91f68d4f90a680d127750bd; -общие члены
- [5] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair Key "x-zumo-version" string Value "Zumo.Main.0.1.6.3017.Runtime" string + Non -общие члены
- [6] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair Ключ "X-Powered-By" строковое значение "ASP.NET" строка + непубличные члены
- [7] {System.Collections.Generic.KeyVal uePair} System.Collections.Generic.KeyValuePair Key "Date" string Value "Thu, 27 Jun 2013 18:23:56 GMT" string + Непубличные члены
+ Raw View
ResponseStatus Microsoft.WindowsAzure.MobileServices. ServiceFilterResponseStatus.ProtocolError Microsoft.WindowsAzure.MobileServices.ServiceFilterResponseStatus StatusCode 404 int StatusDescription Строка «Не найдено»


person Nir Schachter    schedule 27.06.2013    source источник
comment
Каковы подробности объекта исключения?   -  person carlosfigueira    schedule 27.06.2013
comment
@carlosfigueira Я редактировал вопросы с деталями, получаю в ответе 404 not found   -  person Nir Schachter    schedule 27.06.2013
comment
Это выглядит странно: string mobileServiceUrl = "http://MyMoblieService.azure-mobile.net/.azure-mobile.net/ - вы уверены, что у вас правильный URL? Я действительно сомневаюсь, что после доменного имени должно быть ./azure-mobile.net/ ...   -  person carlosfigueira    schedule 27.06.2013
comment
@carlosfigueira, это была проблема, большое спасибо   -  person Nir Schachter    schedule 28.06.2013


Ответы (1)


Как мы обсуждали в комментариях: URL-адрес, который вы передаете конструктору MobileServiceClient, неверен. Ответ "Не найдено" заставил меня посмотреть URL-адрес, который у вас есть:

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

И это неправильно. Это должно быть так, как показано ниже:

public static string mobileServiceUrl =
    "http://MyMoblieService.azure-mobile.net/";
person carlosfigueira    schedule 27.06.2013
comment
Привет, Карлос, я вижу, ты работаешь в команде мобильных сервисов, отлично !! : D Не могли бы вы проверить этот вопрос, если найдете время? Большое спасибо! - person Marco; 25.08.2013