Reputation: 155
I'm using Xamarin for Android and have added the azure mobile services componenet.
I'm trying to create the todo list application like (https://github.com/xamarin/azure-mobile-services)
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);
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);
}
and everytime I get t.IsFaulted = true
, while debuging when I dig in t.Exception I find Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException
I would be glad to supply the rest of the code if needed.
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
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
Upvotes: 2
Views: 1075
Reputation: 87218
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/";
And that's incorrect. It should be as shown below:
public static string mobileServiceUrl =
"http://MyMoblieService.azure-mobile.net/";
Upvotes: 1