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

An error occurred while sending the PostAsync request on Android

$
0
0

hello World,

I got an issue, when I do a postAsync request on android devices.
I already add Internet permission to the manifest.
But I don't understand, cause my code is working fine on IOS Device.

I'm using VisualStudio for Mac. :neutral:

my Code:
var client = new HttpClient();
client.BaseAddress = new Uri(Url);
HttpContent _Body = new StringContent(Body, Encoding.UTF8, "application/json"); => System.net.WebException Error NameResolutionFailure
response = client.PostAsync(Uri, _Body).Result;
response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync();

source of the exception : mscorlib

stacktrace:
at System.Net.Http.HttpClientHandler+d__63.MoveNext () [0x004ab] in <35658e59c86d40bdbb2ef0bb34b4f0c7>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in <35658e59c86d40bdbb2ef0bb34b4f0c7>:0

Hope someone can guide me to resolve this issue
thanks :smile:


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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