Hello I am trying to load data into a web API with a Universal app, but testing with Fiddler will not come out the data in the correct format This should be the result:
{"IDBusta":4,"NomeCliente":"Fior","Prezzo":9.0}]
instead it comes so:
alue=%7B%22IDBusta%22%3A22%2C%22NomeCliente%22%3A%22fff%22%2C%22Prezzo%22%3A22.0%7D
this is the class on question:
public sealed partial class CreateOrUpdate : Page
{
bool? create { get; set; }
public CreateOrUpdate()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Must be a request to update
// Because if the "create" is null or true,
// it is to denote that the request is to create a new object
if (e.Parameter as bool? == false)
{
create = e.Parameter as bool?;
var busta = App.ActiveBusta;
TextBoxIdBusta.Text = busta.IDBusta.ToString();
TextBoxNome.Text = busta.NomeCliente.ToString();
TextBoxPrezzo.Text = busta.Prezzo.ToString();
actionButton.Content = "Update";
}
}
private void Button\_Click(object sender, RoutedEventArgs e)
{
if ((sender as Button).Content.ToString() == "Home")
{
// Go to default page
this.Frame.Navigate(typeof(MainPage));
return; // and cancel the event.
}
// Otherwise
var busta = new Busta
{
IDBusta = Convert.ToInt32(TextBoxIdBusta.Text),
NomeCliente = TextBoxNome.Text.ToString(),
Prezzo = float.Parse(TextBoxPrezzo.Text),
};
using (var client = new HttpClient())
{
var content = JsonConvert.SerializeObject(busta);
if (create == null || create == true)
{
// Send a POST
Task task = Task.Run(async () =>
{
var data = new HttpFormUrlEncodedContent(
new Dictionary
{
\["value"\] = content
}
);
await client.PostAsync(App.BaseUri, data);