Hi, in the following code, I want to send the data via a post service but the app crashes. Here is the code from App.Xaml.cs. Help will be appreciated !!
{
string requestUri = "http://xxxxxxxxxxxxxxxxxxxx";
var uri = new Uri(string.Format(requestUri, string.Empty));
try
{
using (var client = new HttpClient())
using (var content = new MultipartFormDataContent())
{
var values = new[]
{
new KeyValuePair<string, string>("Language","en"),
new KeyValuePair<string, string>("Platform","Android"),
new KeyValuePair<string, string>("Title","abc123")
};
foreach (var keyValuePair in values)
content.Add(new StringContent(keyValuePair.Value), keyValuePair.Key);
using (var result = await client.PostAsync(uri, content))
{
var input = await result.Content.ReadAsStringAsync();
if (result.IsSuccessStatusCode)
{
MainPage = new App1.MainPage();
}
else
{
//do nothing
}
}
}
}
catch (Exception ex)
{
Debug.WriteLine("Failed to submit");
}
}