botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

/api/conversations stop working sine 5/9

Open eddie1976 opened this issue 10 years ago • 13 comments

No conversationId return after HTTP Post

eddie1976 avatar May 09 '16 05:05 eddie1976

Seeing similar. Used to return a 200, now returns a 201, but the DirectLine SDK expects 200 response and therefore is failing the request.

wbreza avatar May 09 '16 06:05 wbreza

Workaround until they either update the SDK or revert back to returning a 200.

try
{
    return await this.directLineClient.Conversations.NewConversationAsync();
}
catch (HttpOperationException ex)
{
    if (ex.Response.StatusCode == HttpStatusCode.Created)
    {
        var conversationJson = await ex.Response.Content.ReadAsStringAsync();
        var conversation = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<Bot.Conversation>(conversationJson);
        return conversation;
    }

    throw;
}

wbreza avatar May 09 '16 07:05 wbreza

I just started having the same problem

ahmet8282 avatar May 09 '16 09:05 ahmet8282

Each conversation on the Direct Line channel must be explicitly started using a POST to the https://directline.botframework.com/api/conversations endpoint. If the call was authorized with a token, the conversation ID is the conversation ID in the scoped token. If a secret was used to start the conversation, the conversation will be started with a new, random ID.

The client may send messages to the bot by calling POST on https://directline.botframework.com/api/messages/conversationId.

eddie1976 avatar May 09 '16 12:05 eddie1976

Are you referring to NewConversationAsync returning 201 instead of returning 200?

ahmet8282 avatar May 09 '16 12:05 ahmet8282

I got 201.

eddie1976 avatar May 09 '16 12:05 eddie1976

ok. so what changed from last week. Last week same code was working and was returning 200. Now, it got broken because it is returning 201. Does this mean, DirectLine Api was changed but the nuget library hasnt updated yet?

ahmet8282 avatar May 09 '16 12:05 ahmet8282

We just pushed out a new release of Direct Line but this broke older clients so I've changed it to return 200 in all cases. Existing clients should work with it for now. If we change its behavior in the future, we'll upgrade the Nuget package before changing the service.

dandriscoll avatar May 09 '16 20:05 dandriscoll

@dandriscoll This type of change should be treated as a breaking change and versioned appropriately. Take the BotConnector API as an example it has a versioned interface. You guys should consider adopting a similar design practice for the DirectLine API.

Saying you'll update the Nuget package in the future will not solve this type of problem since people that have a dependency on the old Nuget package would still be negatively impacted.

wbreza avatar May 09 '16 23:05 wbreza

Sure, good suggestion. Thanks

dandriscoll avatar May 09 '16 23:05 dandriscoll

@dandriscoll To be fair there have been breaking changes introduced that do not conform to standard semantic versioning which Nuget adheres to. On the flip side I also understand that the bot framework is technically still in "preview" mode and that you guys are still finalizing the APIs.

I have also been bit in the recent past when I updated the Nuget packages which appears to only introduce minor version changes but actually included breaking API changes.

wbreza avatar Jun 01 '16 20:06 wbreza

@wbreza I see you posted a workaround where do I put that code?

whatsdis avatar Jun 01 '16 20:06 whatsdis

@whatsdis I don't know if that workaround is still required since they had rolled back the change with regard to the status code. If that workaround is still required you would add it wherever you are calling into the direct line client. If you're not using direct line client then this may be a different issue.

wbreza avatar Jun 01 '16 21:06 wbreza