Can't bind multiple parameters ('header' and 'parameters') to the request's content.
2019-01-23 15:46:29.012+08:00 ERROR [6]:
System.InvalidOperationException: Can't bind multiple parameters ('header' and 'parameters') to the request's content.
at System.Web.Http.Controllers.HttpActionBinding.ExecuteBindingAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at LISA.WebApi.Chile.Helper.CustomMessageHandler.<SendAsync>d__3.MoveNext() in C:\Users\clu\source\repos\Edenred\LISA_6.0.0.0\LISA.CMS.Chile\LISA.WebApi.Chile\Helper\CustomMessageHandler.cs:line 50
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.HttpServer.<SendAsync>d__24.MoveNext()
出现这个错误的原因是,我的controller/action。
action对应的方法,需要2个参数。但是post的时候,request body是一个json字符串。
在目前不做parameter binding的情况下,直接将2个参数更改为1个参数JObject obj。
然后在方法内部,对json字符串进行解析。
dynamic json = obj;
RedemptionInformationRequest parameters =
JsonConverter.DeSerializer<RedemptionInformationRequest>(json.parameters.ToString());
{
"header": {
"SecurityHash": "e1e7b4f072cfd5856a27a31640d5890bf3ccc5af7b5db810fc5e5906ee9f02bd"
},
"parameters": [
{
"TransactionId": "6117",
"Result": "Accredited"
},
{
"TransactionId": "6118",
"Result": "Accepted"
},
{
"TransactionId": "6119",
"Result": "Error"
}
]
}
json的数组是用[]表示的
Can't bind multiple parameters ('header' and 'parameters') to the request's content.的更多相关文章
- Laravel 5.7 No 'Access-Control-Allow-Origin' header is present on the request resource
前后端项目跨域访问时会遇到此问题,解决方法如下: 创建一个中间件 php artisan make:middleware EnableCrossRequestMiddleware 该中间件的文件路径为 ...
- How to implement multiple constructor with different parameters in Scala
Using scala is just another road, and it just like we fall in love again, but there is some pain you ...
- Parameters.Add和Parameters.AddWithValue
因为vs2013没有更新update 5所以Parameters.Add可以用Parameters.AddWithValue赋值无效 更新后可以. Parameters.AddWithValue的底层 ...
- Multiple actions were found that match the request in Web Api
https://stackoverflow.com/questions/14534167/multiple-actions-were-found-that-match-the-request-in-w ...
- 从response.header中提取cookie,在request里添加cookie
// List<String> resp = new ArrayList<String>(); // HeaderIterator headers ...
- Multiple actions were found that match the request Web API
在WebAPI工程入口不对外公开的接口不能使用public. [HttpPost] public string PostRequest([FromBody] Model model) { /// } ...
- Parameter Binding in ASP.NET Web API
https://docs.microsoft.com/en-us/aspnet/web-api/overview/formats-and-model-binding/parameter-binding ...
- asp.net web api [FromBody]参数
Using jQuery to POST [FromBody] parameters to Web API 时间2013-04-04 00:28:17 Encosia原文 http://encosia ...
- Asp.Net WebAPI Get提交、Post提交处理
1.启用跨域提交 <system.webServer> <httpProtocol> <customHeaders> <add name="Acce ...
随机推荐
- Linux增加swap分区的方法
在装完Linux系统之后,建立Swap分区有两种方法. 1.新建磁盘分区作为swap分区2.用文件作为swap分区 (操作更简单,我更常用) 一.新建磁盘分区作为swap分区 1. # swapoff ...
- Html5-Canvas 与 SVG 的比较
Canvas 与 SVG 的比较 Canvas 依赖分辨率 不支持事件处理器 弱的文本渲染能力 能够以 .png 或 .jpg 格式保存结果图像 最适合图像密集型的游戏,其中的许多对象会被频繁重绘 S ...
- devmapper: Thin Pool has 162394 free data blocks which is less than minimum required 163840 free data blocks
问题: 制作镜像的时候报错 devmapper: Thin Pool has 162394 free data blocks which is less than minimum required 1 ...
- Contos更换python版本
1.查看版本 #python -VPython 2.6.6 2.安装前准备,安装相关库#yum install gcc gcc-c++ autoconf automake#yum install op ...
- Universally Unique Identifier amazonservices API order 亚马逊订单接口的分析 NextToken
one hour in linux mysql> ) from listorders; +----------+ | count() | +----------+ | | +---------- ...
- FW: git internal
Git 内部原理 不管你是从前面的章节直接跳到了本章,还是读完了其余各章一直到这,你都将在本章见识 Git 的内部工作原理和实现方式.我个人发现学习这些内容对于理解 Git 的用处和强大是非常重要的, ...
- Android安装APK报错:Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE解决方法
今天调试一个android应用的时候,安装报了Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE错误,代码如下: [2015-12-28 15 ...
- 在Centos上打Preempt-rt实时补丁(续)
经过上一篇,发现2.6.31版本的补丁不能正常运行(还未找到原因),现改用2.6.33版本: kernel:linux-2.6.33.9 patch:patch-2.6.33.9-rt 解压并打好补丁 ...
- 关于mysql主从复制的概述与分类
一.概述: 按照MySQL的同步复制特点,大体上可以分为三种类别: 1.异步复制: 2.半同步复制: 3.完全同步的复制: -------------------------------------- ...
- [设计模式]迭代子模式 Iterator
迭代子模式又叫做游标cursor模式,是对象的行为模式.迭代子模式可以顺序的访问一个聚集中的元素而不必暴露聚集的内部表象. 迭代子模式被广泛的应用在Java语言的API中的几个设计模式之一.在Java ...