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. python 之 re模块(正则表达式)

    一.起源(历史) 正则表达式的“鼻祖”或许可一直追溯到科学家对人类神经系统工作原理的早期研究.美国新泽西州的Warren McCulloch和出生在美国底特律的Walter Pitts这两位神经生理方 ...

  2. shared_ptr & weak_ptr

    shared_ptr <1> 类模板说明 namespace boost { class bad_weak_ptr: public std::exception; template< ...

  3. WebService之XFire和SOAP实例(基于JAVA)

    开发环境:jdk1.6 + Tomcat7 + MyEclipse10 源码下载地址张贴在文章最后面:首先是使用WSDL协议实现:这里使用XFire XFire一个免费.开源的SOAP框架,它构建了P ...

  4. 【Python基础】装饰器的解释和用法

    装饰器的用法比较简单,但是理解装饰器的原理还是比较复杂的,考虑到接下来的爬虫框架中很多用到装饰器的地方,我们先来讲解一下. 函数 我们定义了一个函数,没有什么具体操作,只是返回一个固定值 请注意一下缩 ...

  5. 160726、jQuery常用操作

    一.简介   定义  jQuery创始人是美国John Resig,是优秀的Javascript框架: jQuery是一个轻量级.快速简洁的javaScript库. jQuery对象  jQuery产 ...

  6. JavaScript学习笔记-构造函数

    什么是构造函数 简单说构造函数是类函数,函数名与类名完全相同,且无返回值.构造函数是类的一个特殊成员函数. JavaScript构造函数 * 在JavaScript的世界里没有类的概念,JavaScr ...

  7. mysql线上操作常用命令

    备份命令: mysqldump -uroot -p --default-character-set=utf8 --hex-blob -R --log-error=/var/log/backup-log ...

  8. hdu 1257 最少拦截系统【贪心 || DP——LIS】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1257 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  9. where case 使用

    1 traceroleid表数据 tracerleid 表放着角色的相关信息, 角色ID 角色类型 密码 2 traceaccountmap表数据 表中存放着客户号和 其他角色的关系 tracerol ...

  10. thinkphp5, 隐藏index.php

    tp5官网手册里的代码有误, 注意防坑, 正确的应该是: 修改.htaccess文件: <IfModule mod_rewrite.c> Options +FollowSymlinks R ...