找回密码
 立即注册

QQ登录

只需一步,快速开始

yy5512
金牌服务用户   /  发表于:2023-3-20 11:35  /   查看:856  /  回复:1
1金币
交付项目的时候,遇到一个问题,麻烦大神帮忙解答一下

需求场景:我方利用活字格提供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类型?
附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册

最佳答案

查看完整内容

大佬您好,这个问题可能要通过demo才能具体的分析, 需要您附上一个可以复现问题的工程文件和说明操作步骤。这样我们这边可以更好地理解您的问题,更好的帮助到您哦~

1 个回复

倒序浏览
最佳答案
最佳答案
Grayson.Shang活字格认证 Wyn认证
超级版主   /  发表于:2023-3-20 11:35:41
来自 2#
大佬您好,这个问题可能要通过demo才能具体的分析
需要您附上一个可以复现问题的工程文件和说明操作步骤。这样我们这边可以更好地理解您的问题,更好的帮助到您哦~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部