Connecting WordPress and Xamarin

Do you have a WordPress website and need to connect it to you Xamarin mobile application?
By “connect” I mean:

  • User Creation
  • User Roles
  • Login
  • View Post or Page
  • Add Post or Page
  • Edit Post or Page
  • Delete Post or Page
  • Load Images
  • Upload Images
  • View Comments
  • Add Comment to Post
  • Edit Comments
  • Custom Post Types

I use Xamarin Forms and WordPress exclusively to make social media, map/location, chat, data entry, games and more.

Here is a simple GET to retrieve a WordPress Post by its Post ID. Im calling the WordPress REST API endpoint. WordPress always returns an Array object, so you have to loop through the results and create your Posts Class as a List.

public async Task<List> GetPosts()
            Models.Helper help = new Models.Helper();
            Models.Post model = new Models.Post();
            List list = new List();
            using (var client = new HttpClient())
                string qry = "?posts/?id=123";
                var uri = new Uri(string.Format(help.WebAPIAddress() + qry, string.Empty));
                var resp = await client.GetAsync(uri);
                if (resp.IsSuccessStatusCode)
                    var json = await resp.Content.ReadAsStringAsync();
                    JArray j = JArray.Parse(json);
                    string mp3Url = help.WebAPIAddress() + help.MP3Endpoint();
                    foreach (var p in j)
                        Models.Postmod = new Models.Post();
                        mod.Description = help.RemoveHtmlFormatting((string)p["content"]["rendered"]);
                        mod.Title = help.RemoveHtmlFormatting((string)p["title"]["rendered"]);
                        mod.Id = (int)p["id"];
                    Models.Postmod = new Models.Post();
                    mod.ErrorMessage = "There was an error. Please try again.";
            return list;


12861cookie-checkConnecting WordPress and Xamarin