Unable to deserialize the response - GetUserDataAs

2019-09-20 17:02发布

问题:

I am working bot technology, in one of my project I used bot state concept to get the bot data and set new data here I used state client object like this below

 //var stateClient = new StateClient(new Uri("http://localhost:9000/"));
   var stateClient = new StateClient(new Uri("https://skype.botframework.com"));

This is code I wrote in LoginController.cs

                if (stateClient != null)
                {
                    var getData = await stateClient.BotState.GetUserDataAsync(Constants.Constants.botId, activity.From.Id);// 29:1_12CsCTqilHlQTG9KI8YmvCKd - zwzekm2IDKR7xN8EVE3gjtfNQYp1aOzuC9Rs_t
                    //var getData = await client.B.GetUserDataAsync(Constants.Constants.botId, userid);
                    getData.Data = ar.Serialize();
                    var foo = await stateClient.BotState.SetUserDataAsync(Constants.Constants.botId, activity.From.Id, getData);
                    //var foo = await client.Bots.SetUserDataAsync(Constants.Constants.botId, userid, getData);
                }

The above code will work in bot emulator successfully without exception. but when I added bot to skype then started to chat at that time I am getting exception 'Unable to deserialize the response' after executed this line

var getData = await stateClient.BotState.GetUserDataAsync(Constants.Constants.botId, activity.From.Id);

Please tell me how resolve it.

回答1:

You might need to use https://state.botframework.com as the endpoint for the StateClient rather than skype.botframework.com.