我正在使用Postman向Azure托管的应用服务发出http post请求。
但是,当尝试反序列化正在发送的对象时,我收到错误
" exceptionMessage":"输入字符串' ---------------------------- 020872859577165253890409'不是有效的数字。路径'',第1行,第52位。
下面是正在发送的对象的图像
这是应该处理Post请求的代码
public async Task<HttpResponseMessage> Post(HttpRequestMessage req)
{
Console.WriteLine("Reached api function");
string jsonContent = await req.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonContent); //errors out here
return new HttpResponseMessage(HttpStatusCode.OK);
}
编辑:
我已经改变了代码,通过执行
来返回jsonContent对象public async Task<HttpResponseMessage> Post(HttpRequestMessage req)
{
string jsonContent = await req.Content.ReadAsStringAsync();
return Request.CreateResponse(HttpStatusCode.BadRequest, jsonContent);
}
邮递员的回应是
"----------------------------492273134681850811150096\r\nContent-Disposition: form-data; name=\"id\"\r\n\r\n932\r\n----------------------------492273134681850811150096\r\nContent-Disposition: form-data;
name=\"response\"\r\n\r\nThis is a test\r\n----------------------------492273134681850811150096\r\nContent-Disposition: form-data;
name=\"activities\"\r\n\r\nFun and stuff, Other\r\n----------------------------492273134681850811150096\r\nContent-Disposition: form-data;
name=\"contact\"\r\n\r\nyesman12@yahoo.com\r\n----------------------------492273134681850811150096--\r\n"