2
Hello, folks! I am trying to implement a method to update (update) information in a WPF application. Apparently, everything is correct, however, the method does not work. Here is the code:
This is the PUT on the server side (Controller):
public void Put(int id, [FromBody] string value)
{
Models.lok x = JsonConvert.DeserializeObject
<Models.lok>(value);
Models.PatDataContext dc = new Models.PatDataContext();
Models.lok rsk = (from r in dc.Registras
where r.id == id
select r).Single();
rsk.nome = x.nome;
rsk.observacao = x.observacao;
dc.SubmitChanges();
}
And this is what’s in the customer:
private async void btnAlterar_Click(object sender, RoutedEventArgs e)
{
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(http://localhost:60417/);
Modelo.Jos sa = new Modelo.Jos
{
Id = int.Parse(textBoxID.Text),
Nome = textBoxNome.Text,
Observacao = textBoxObs.Text
};
string seria = "=" + JsonConvert.SerializeObject(sa);
var content = new StringContent(seria, Encoding.UTF8, "application/x-www-form-urlencoded");
await httpClient.PutAsync("/api/Jos" + sa.Id, content);
}
Thank you very much!
Do not post code link, post code itself.
– Marco Souza
All right. Thank you!
– Kádson
which method does not work?
– Marco Souza