Hi, I cant figure out what is wrong in here as it keep failing, previously I was using same code in UWP. But now I want to execute it in Xamarin forms app. Please help? Here is my code....
public async void MachineLearning()
{
try
{
using (var client = new HttpClient())
{
var request = new
{
Inputs = new Dictionary<string, StringTable>() {
{
"User_Name_input",
new StringTable()
{
ColumnNames = new string[] {"User_Name", "Type"},
Values = new string[,] { {"Drake", "Celebrity" } }
}
},
},
GlobalParameters = new Dictionary<string, string>()
{
}
};
const string key = "*****************************************************************************";
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", key);
client.BaseAddress = new Uri("*****************************************************************");
HttpResponseMessage response = await client.PostAsJsonAsync("", request).ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
Rootobject obj = JsonConvert.DeserializeObject<Rootobject>(result);
string MyResult = (String.Format("{0}", obj.Results.User_data.value.Values[0][15]));
DisplayAlert(MyResult, MyResult, "OK");
}
else
{
DisplayAlert("WARNING", "The request failed", "Ok");
}
}
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
}