Botstate.SetConversationData - 解析值时遇到意外字符
Botstate.SetConversationData - Unexpected character encountered while parsing value
我正在尝试通过状态客户端保存对话数据,但在模拟器和短信渠道之间得到的结果不一致。通过模拟器测试我的机器人应用程序允许我 SetConversationData 和 GetConversationData 正常,但是当我在带有服务 url 的短信上尝试它时:https://sms.botframework.com/ 我收到以下错误:
"exceptionMessage": "Unable to deserialize the response.",
"exceptionType": "Microsoft.Rest.SerializationException",
"stackTrace": " at Microsoft.Bot.Connector.BotState.d__9.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Connector.BotStateExtensions.d__9.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Connector.BotStateExtensions.SetConversationData(IBotState operations, String channelId, String conversationId, BotData botData)\r\n at OutboundTestApp.Controllers.OutboundController.Post(OutboundConversationData`1 outboundData)",
"innerException": {
"message": "An error has occurred.",
"exceptionMessage": "Unexpected character encountered while parsing value: T. Path '', line 0, position 0.",
"exceptionType": "Newtonsoft.Json.JsonReaderException",
"stackTrace": " at Newtonsoft.Json.JsonTextReader.ParseValue()\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject[T](String json, JsonSerializerSettings settings)\r\n at Microsoft.Bot.Connector.BotState.d__9.MoveNext()"
这是我设置数据的代码,其中 channelId 是 "sms",conversationId 是一个有效的 id,数据只是一个简单的 POCO class:
var stateClient = new StateClient(new Uri(serviceUrl), account);
stateClient.BotState.SetConversationData(outboundData.ChannelId, conversationResponse.Id, new BotData(data: outboundData.Data));
我是否应该使用 SetPrivateConversationDataWithHttpMessagesAsync 并传入内容类型并将我的 botdata 设置为 json 字符串?我觉得状态客户端假设 json 正在某处传递,但它正在反序列化的对象实际上不是 json。
问题是创建状态客户端时serviceUrl设置错误。 baseUri 应该是 https://state.botframework.com。
我正在尝试通过状态客户端保存对话数据,但在模拟器和短信渠道之间得到的结果不一致。通过模拟器测试我的机器人应用程序允许我 SetConversationData 和 GetConversationData 正常,但是当我在带有服务 url 的短信上尝试它时:https://sms.botframework.com/ 我收到以下错误:
"exceptionMessage": "Unable to deserialize the response.", "exceptionType": "Microsoft.Rest.SerializationException", "stackTrace": " at Microsoft.Bot.Connector.BotState.d__9.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Connector.BotStateExtensions.d__9.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Connector.BotStateExtensions.SetConversationData(IBotState operations, String channelId, String conversationId, BotData botData)\r\n at OutboundTestApp.Controllers.OutboundController.Post(OutboundConversationData`1 outboundData)", "innerException": { "message": "An error has occurred.", "exceptionMessage": "Unexpected character encountered while parsing value: T. Path '', line 0, position 0.", "exceptionType": "Newtonsoft.Json.JsonReaderException", "stackTrace": " at Newtonsoft.Json.JsonTextReader.ParseValue()\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject[T](String json, JsonSerializerSettings settings)\r\n at Microsoft.Bot.Connector.BotState.d__9.MoveNext()"
这是我设置数据的代码,其中 channelId 是 "sms",conversationId 是一个有效的 id,数据只是一个简单的 POCO class:
var stateClient = new StateClient(new Uri(serviceUrl), account);
stateClient.BotState.SetConversationData(outboundData.ChannelId, conversationResponse.Id, new BotData(data: outboundData.Data));
我是否应该使用 SetPrivateConversationDataWithHttpMessagesAsync 并传入内容类型并将我的 botdata 设置为 json 字符串?我觉得状态客户端假设 json 正在某处传递,但它正在反序列化的对象实际上不是 json。
问题是创建状态客户端时serviceUrl设置错误。 baseUri 应该是 https://state.botframework.com。