Answer the question
In order to leave comments, you need to log in
How to parse POST request with dynamic data in WEB API?
Good afternoon.
In my view, the script generates an unknown amount of data in advance, and then sends them with a post request. I found an article where it says that in the class you can make a Dictionary dictionary, and send data using []
So I did:
public Dictionary<string, object> Column { get; set; }
Column%5BP5%5D=&Column%5BP6%5D=71&Column%5BP7%5D=100%25+-+%D1%85%D0%BB%D0%BE%D0%BF%D0%BE%D0%BA&Column%5BP8 %5D=&Column%5BP9%5D=&Column%5BP10%5D=&
public async Task<ActionResult> EditAModel(ModelView data)
{
// обработка
}
public async Task<IHttpActionResult> EditModelList()
{
string result = await Request.Content.ReadAsStringAsync();
var data = JsonConvert.DeserializeObject<ModelView>(result); // Не парсит, выдает ошибку
return Ok();
}
Answer the question
In order to leave comments, you need to log in
So, you are not getting JSON, how are you going to parse it with JsonConvert?
Here result is a set of keys and values, not a json object.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question