交付项目的时候,遇到一个问题,麻烦大神帮忙解答一下
需求场景:我方利用活字格提供WEBAPI,供第三方调用传入数据。
写好服务端命令之后,目前我用第三方工具POSTMAN测试时,仅能通过编码方式为默认的x-www-form-urlencoded来接收数据
当调用模式改成RAW-JSON之后就会报错
错误内容如下
Request Exception Happened-------------------------------
Path/ServerCommand/ITEM_ADD
{
"ClassName": "Newtonsoft.Json.JsonSerializationException",
"Message": "Error converting value \"ITEM_JSON\" to type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'. Path '', line 1, position 12.",
"Data": null,
"InnerException": {
"$type": "System.ArgumentException, System.Private.CoreLib",
"ClassName": "System.ArgumentException",
"Message": "Could not cast or convert from System.String to System.Collections.Generic.Dictionary`2[System.String,System.Object].",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)
at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": -2147024809,
"Source": "Newtonsoft.Json",
"WatsonBuckets": null,
"ParamName": null
},
"HelpURL": null,
"StackTraceString": " at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Forguncy.KatanaMiddleware.ServerCommandExecutor.a(HttpRequest A_0)
at Forguncy.KatanaMiddleware.ServerCommandExecutor.ExecuteCommand(String commandName, Boolean isServerCommand, HttpContext context, Boolean runFromAdimnPortal)
at Forguncy.KatanaMiddleware.ServerCommandMiddleware.InvokeAsync(HttpContext context)
at Forguncy.KatanaMiddleware.k.InvokeAsync(HttpContext context)
at Forguncy.KatanaMiddleware.j.InvokeAsync(HttpContext context)
at Forguncy.Server2.KatanaMiddleware.StartPageMiddleware.InvokeAsync(HttpContext context)
at ForguncyServerCommon.HttpHeaderMiddlewareBase.InvokeAsync(HttpContext context)
at Forguncy.KatanaMiddleware.q.InvokeAsync(HttpContext context)",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": -2146233088,
"Source": "Newtonsoft.Json",
"WatsonBuckets": null
}
是我设置有问题还是POSTMAN传参数格式有问题?还是活字格目前不支持传入JSON类型?
|