0
votes

Im using Xamarin Studio and Microsoft Azure to create an IOS App. I am trying to connect the table I created in the Microsoft Azure Mobile Services to my app and I am having some trouble.

I created a new mobile service and a new table called "UsersTable" in the Microsoft Azure Portal. I then went to my code and started to connect to the table. Here is what I have:

UsersService.cs:

using System.Collections.Generic;
using MonoTouch.Foundation;
using System.Threading.Tasks;
using MonoTouch.UIKit;
using System.Net.Http;
using Microsoft.WindowsAzure.MobileServices;

namespace Practice_IOS
{
    public class UsersService
    {
        private MobileServiceClient client;
        private IMobileServiceTable<UsersTable> usersTable;

        public List<UsersTable> Person { get; private set;}

        protected UsersService ()
        {
            CurrentPlatform.Init ();

            Person = new List<UsersTable>();

            client = new MobileServiceClient (UsersConstants.ApplicationURL, UsersConstants.ApplicationKey, this);  
            usersTable = client.GetTable<UsersTable>();
        }
    }
}

UsersTable.cs

using System;
using Newtonsoft.Json;

namespace Practice_IOS
{
    public class UsersTable
    {
        public string Id { get; set; }

        [JsonProperty(PropertyName = "name")]
        public string Name { get; set; }

        [JsonProperty(PropertyName = "email")]
        public bool Email { get; set; }

        [JsonProperty(PropertyName = "password")]
        public string Password { get; set; }
    }
}

UsersConstants.cs:

using System;

namespace Practice_IOS
{
    public static class UsersConstants
    {
        public const string ApplicationURL = @"https://practiceusersxamatin.azure-mobile.net/";
        public const string ApplicationKey = @"SecretKeyGoesHere";
    }
}

When I go to build it, it gets to the following line of code

client = new MobileServiceClient (UsersConstants.ApplicationURL, UsersConstants.ApplicationKey, this);

it tells me "Argument #3 cannot convert 'Practice.IOS.UsersService' expression to type System.Net.Http.HttpMessageHandler[]". How can I get this to be taken as an argument

I am using this tutorial http://azure.microsoft.com/en-us/documentation/articles/partner-xamarin-mobile-services-ios-get-started-data/ to help me try and connect.

1
You should not post your AppKey. - Chief Wiggum
That one is just made up and so is the ApplicationURL. I just wanted to show that I had them in there. - eric walier
Check the tutorial again. It shows the constructor for the client class with only 2 arguments. - Jason
Oh wow I didn't even notice that. Although, it shows the first two arguments being the same, but it adds a ".withFilter()" function to the end of it were they pass in this. When I try to do that it tells me ".withFilter" is not defined and I might be missing an assembly. I don't think I am missing an assembly though because I have the exact same assemblies as the tutorial project. - eric walier
I just think the tutorial is out of date - eric walier

1 Answers

0
votes

I'm not familiar with a Constructor overload that needs an instance of "this" for Azure Mobile Service Client. Are you sure you need the third parameter? I've always just used URL and API Key as they two parameters.