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.的更多相关文章

  1. Laravel 5.7 No 'Access-Control-Allow-Origin' header is present on the request resource

    前后端项目跨域访问时会遇到此问题,解决方法如下: 创建一个中间件 php artisan make:middleware EnableCrossRequestMiddleware 该中间件的文件路径为 ...

  2. 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 ...

  3. Parameters.Add和Parameters.AddWithValue

    因为vs2013没有更新update 5所以Parameters.Add可以用Parameters.AddWithValue赋值无效 更新后可以. Parameters.AddWithValue的底层 ...

  4. 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 ...

  5. 从response.header中提取cookie,在request里添加cookie

    //        List<String> resp = new ArrayList<String>();  //        HeaderIterator headers ...

  6. Multiple actions were found that match the request Web API

    在WebAPI工程入口不对外公开的接口不能使用public. [HttpPost] public string PostRequest([FromBody] Model model) { /// } ...

  7. Parameter Binding in ASP.NET Web API

    https://docs.microsoft.com/en-us/aspnet/web-api/overview/formats-and-model-binding/parameter-binding ...

  8. asp.net web api [FromBody]参数

    Using jQuery to POST [FromBody] parameters to Web API 时间2013-04-04 00:28:17 Encosia原文 http://encosia ...

  9. Asp.Net WebAPI Get提交、Post提交处理

    1.启用跨域提交 <system.webServer> <httpProtocol> <customHeaders> <add name="Acce ...

随机推荐

  1. tomcat报错-----》Unable to open debugger port IDEA Unable to open debugger port

    原因:IDEA配置的端口被占用了 解决方法: 方法一: 查找idea配置的调试端口--查看占用该端口的进程--杀掉进程 方法二:查找idea配置的调试端口--修改调试端口(未被使用的) 基本步骤: 1 ...

  2. Array转为Json需要导入的包

    今天自己写了一个JSON的例子,可以一调用就出了问题,报下面这个异常: java.lang.ClassNotFoundException: org.apache.commons.lang.except ...

  3. Hbase的shell命令学习

    在学习Hbase的shell命令,之前先得了解如何进入hbase的shell命令行,通过执行如下简单的命令回车后进入hbase的shell命令行界面 hbase shell 进入hbase命令行后,执 ...

  4. 显示excel工作簿中所有工作表的名称!!!

    问题描述: 有一个工作簿里边将近二百多个工作表(公司),想统计里边所有公司名称即二百多个工作表的名称. 1.找一个空白工作表,也可以利用原来工作表中不用的列,转到“公式”工具栏,点击名称管理,在跳出来 ...

  5. textarea输入字符有限制

    function limitedNumberOfInputCharacters(limitedNumber, string){ var strLength = 0; if(string !== nul ...

  6. 求其中同一个主叫号码的两次通话之间间隔大于10秒的通话记录ID

    求其中同一个主叫号码的两次通话之间间隔大于10秒的通话记录ID 例如:6,7,8,9,10条记录均符合 ID 主叫号码 被叫号码      通话起始时间            通话结束时间       ...

  7. 如何使用android studio及夜神模拟器开发调试

    android studio 只安装sdk(不安装自带模拟器)1.下载并安装夜神模拟器 2.先启动夜神模拟器 3.然后运行cmd命令,cd到夜神安装目录(bin目录下),执行命令: nox_adb.e ...

  8. 第四课(2)——mysql配置参数讲解

    *****************general***************** user 启动mysql domain的用户 port 数据库端口号 socket 数据库socket文件的路径 p ...

  9. 如果"一切是IO"“一切是file”是成立的,那么上述的想法也一定可以实现吧 awk对apache日志分析 ---

    定时执行 自动化处理 直接入库 再去读取这个file入库: root@VM---ubuntu:/var/log/apache2# awk '{print $1 "\t" $7}' ...

  10. python 三行代码实现快速排序

    python 三行代码实现快速排序 最近在看 python cookbook , 里面的例子很精彩,这里就帮过来,做个备忘录 主要利用了行数的递归调用和Python的切片特性,解释一下每行代码的含义: ...