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 ...
随机推荐
- 报错 findMergedAnnotation activemq
springmvc 集成activemq引入activemq-all-5.14.4有冲突 springmvc 4.2.9集成activemq-5.14.4时报错,错误信息如下 NoSuchMethod ...
- NET Framework 4.5新特性 (二) 控制台支持 Unicode (UTF-16) 编码
从 .NET Framework 4.5 开始,Console 类支持与 UnicodeEncoding 类的 UTF-16 编码. 显示 Unicode 字符到控制台,你可以设置 OutputEn ...
- jQuery.each(object, [callback])数组对象操作--jQuery 对象访问 $().each(callback)
jQuery.each(object, [callback]) 通用例遍方法,可用于例遍对象和数组. 不同于例遍 jQuery 对象的 $().each() 方法,此方法可用于例遍任何对象.回调函数拥 ...
- Fiddler 抓包工具使用详解
博客园 首页 新随笔 联系 订阅 管理 随笔 - 20 文章 - 0 评论 - 64 Fiddler 抓包工具总结 阅读目录 1. Fiddler 抓包简介 1). 字段说明 2). Statis ...
- 每隔10秒钟打印一个“Helloworld”
/** * 每隔10秒钟打印一个“Helloworld” */ public class Test03 { public static void main(String[] args) throws ...
- pandas 如何判断指定列是否(全部)为NaN(空值)
判断某列是否有NaN df['$open'].isnull().any() # 判断open这一列列是否有 NaN 判断某列是否全部为NaN df['$open'].isnull().all() # ...
- rest_framework之url控制器详解
一 自定义路由(原始方式) from django.conf.urls import url from app01 import views urlpatterns = [ url(r'^books/ ...
- 静默安装oracle 11g及参数配置优化详解
一.安装前准备工作1.修改主机名#vi /etc/hosts //并添加内网IP地址对应的hostname,如下127.0.0.1 localhost::1 ...
- exp导出一个表中符合查询条件的数据
原文地址:exp导出一个表中符合查询条件的数据 作者:charsi 导出一个表中的部分数据,使用QUERY参数,如下导出select * from test where object_id>50 ...
- const,var,let区别(转载)
1.const定义的变量不可以修改,而且必须初始化. const b = 2;//正确 // const b;//错误,必须初始化 console.log('函数外const定义b:' + b);// ...