question

EduardoGomez-4998 avatar image
0 Votes"
EduardoGomez-4998 asked NavtejSaini-MSFT commented

Xamarin azure integration problem

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



dotnet-xamarinazure-sql-database
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Please remove your repo link , since it contains private license information.

0 Votes 0 ·

@EduardoGomez-4998 Hope this is resolved for you. Please let us know if you need further help.

0 Votes 0 ·

1 Answer

ColeXia-MSFT avatar image
0 Votes"
ColeXia-MSFT answered ColeXia-MSFT edited

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.



capture.png (2.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.