Xamarin azure integration problem

Eduardo Gomez 1 Reputation point
2021-04-02T22:50:30.21+00:00

Hello everyone

I have an issue

I have a backend in azure, I did a little console application to test it out

using AzureTest;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;

const string Url = "http://xamxontacts.azurewebsites.net/tables/contact?ZUMO-API-VERSION=2.0.0";

using (HttpClient client = new HttpClient()) {

var request = await client.GetAsync(Url);
if (request.IsSuccessStatusCode) {

    var content = await request.Content.ReadAsStringAsync();
    var res = JsonConvert.DeserializeObject<List<Contacts.Contact>>(content);

    foreach (var item in res) {

        Console.WriteLine(item.name);
    }
}

}

but when I go to my Xamarin app, I cannot retrieve anything or post or update or do anything

https://github.com/eduardoagr/XamContact

this is the URL I am trying toi do crud operation on

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
Azure SQL Database
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-04-05T08:18:32.673+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I test your code and got the error below

    84298-capture.png

    The error happens because From Android 9 Http is treated as insecure connection, to enable it we need to modify the config in android project .

    Workaround

    Add [assembly:Application(UsesCleartextTraffic =true)] in AssemblyInfo.cs .

    Refer to https://forums.xamarin.com/discussion/comment/388862/#Comment_388862 .


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments