Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Retrieve JSON from api in XF

$
0
0

I am learning about Azure Mobile Services and trying to follow along to a slightly older tutorial. I built a simple API backed in asp.net core that returns the following JSON from the URL: https://somebackend.azurewebsites.net/api/todo

[{"id":1,"text":"Item1","isComplete":false}]

I have an on_click method that I am trying to use to retrieve this data.

using Microsoft.WindowsAzure.MobileServices;
.
.
.
private async void Button_OnClicked(object sender, EventArgs e)
{
message.Text = "Loading items...";

        MobileServiceClient client = new MobileServiceClient("https://somebackend.azurewebsites.net/api/todo");
        var items = await client.GetTable<TodoItem>().ReadAsync();
        var item = items.First();

        message.Text = item.Text;

    }

The GetTable line is where everything is breaking. Is that line trying to do a GET request on tables/todoitem ....or is it sending the request from my URL? Am I retrieving this incorrectly? It doesn't work on either Android or iOS simulators, and debugging in VS just says error...but not very helpful. I am not exactly sure how to debug the incoming request from my simulators.

In the attached project, I have the backend that I uploaded to Azure, as well as the Xamarin project.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>