[Question] Bad Request (400) Error after calling messaging Hero Card and calling await method
Hello I have a method A which is called after choosing option from PrompDialog.Choice. This method A then calls an Adaptive Card which has a Select button for the user to select from given options in card.
private async Task OnFlightClassSelection(IDialogContext context, IAwaitable<string> result)
{
string optionSelected = await result;
context.PrivateConversationData.SetValue<string>(BOTBackEndData.flightClass, optionSelected);
//get data for flight query
string fromAirportCode = "";
context.PrivateConversationData.TryGetValue(BOTBackEndData.fromAirportCode, out fromAirportCode);
string fromCity = "";
context.PrivateConversationData.TryGetValue(BOTBackEndData.fromDestination, out fromCity);
string toAirportCode = "";
context.PrivateConversationData.TryGetValue(BOTBackEndData.toAirportCode, out toAirportCode);
string toCity = "";
context.PrivateConversationData.TryGetValue(BOTBackEndData.toDestination, out toCity);
string numAdtChdInf = "";
context.PrivateConversationData.TryGetValue(BOTBackEndData.numAdtChdInf, out numAdtChdInf);
string departtDate = "";
context.PrivateConversationData.TryGetValue(BOTBackEndData.departtDate, out departtDate);
string retDate = "";
context.PrivateConversationData.TryGetValue(BOTBackEndData.retDate, out retDate);
int iMarker = 0;
try
{
//TripsSearchResponse objDepartFlight = FetchFlightDetails.FetchFlightData(fromAirportCode, toAirportCode, numAdtChdInf, departtDate, retDate);
TripsSearchResponse objFlights = FetchFlightDetails.FetchFlightData(fromAirportCode, toAirportCode, numAdtChdInf, departtDate, retDate);
iMarker = 1;
string reply = "Kindly click on 'Select' button to choose from the below flight options.";
context.PrivateConversationData.SetValue<BOTBackEndData.Questions>(BOTBackEndData.prevQuestion, BOTBackEndData.Questions.FlightChoice);
await context.PostAsync(reply);
iMarker = 2;
var message = context.MakeMessage();
message.AttachmentLayout = "carousel";
context.PrivateConversationData.SetValue<TripsSearchResponse>(BOTBackEndData.fetchedFlightDetails, objFlights);
//context.PrivateConversationData.SetValue<TripsSearchResponse>(BOTBackEndData.fetchedDeptFlightDetails, objDepartFlight);
//context.PrivateConversationData.SetValue<BOTBackEndData.Questions>(BOTBackEndData.prevQuestion, BOTBackEndData.Questions.FlightDeptChoice);
context.PrivateConversationData.SetValue<BOTBackEndData.Questions>(BOTBackEndData.prevQuestion, BOTBackEndData.Questions.FlightChoice);
//message.Attachments = FetchFlightDetails.GetFlightDataInHeroCard(objDepartFlight);
message.Attachments = FetchFlightDetails.GetFlightDataInAdaptiveCard(objFlights, fromAirportCode, toAirportCode, fromCity, toCity);
await context.PostAsync(message);
//context.Wait(OnDepartFlightSelectionNew);
context.Wait(OnFlightSelectionAdaptive);
}
catch (Exception ex)
{
await context.PostAsync(iMarker + "\nRetDate:" + retDate + "\nDeptdate:" + departtDate + "\nPassengers:" + numAdtChdInf + "\nThere is some error in OnFlightClassSelection. Clearing everything\n------------- \n" + ex.Message + "\n" + ex.StackTrace);
context.PrivateConversationData.Clear();
context.Wait(MessageReceived);
}
}
Once the code messages these cards, I have written context.Wait(OnFlightSelectionAdaptive). So when user clicks on the select I can capture his choice and use it further. But as soon as the carousel of Adpative cards are show, my bot throws an error-
Sorry, my bot code is having an issue. The remote server returned an error: (400) Bad Request
Can somebody help with what could be going wrong.
I have the exact same error on NodeJs. Works with cards and carrousel when testing local. But when putting online (tested on Telegram and webchat), got error 400 post when sending hero card or carrousel
@victorgarciaesgi please open a new issue