public async Task StartConversationAsync()

in libraries/Streaming/StreamingConversations.cs [84:117]


        public async Task<Conversation> StartConversationAsync(TokenParameters tokenParameters = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (SocketClient == null)
            {
                throw new InvalidOperationException("Connection is not opened.");
            }

            var request = new StreamingRequest()
            {
                Verb = "POST",
                Path = "/v3/directline/conversations"
            };

            if (tokenParameters != null)
            {
                request.SetBody(tokenParameters);
            }

            var response = await SocketClient.SendAsync(request).ConfigureAwait(false);

            if (response.StatusCode != 200 && response.StatusCode != 201)
            {
                var body = response.ReadBodyAsStringAsync().ConfigureAwait(false);
                var ex = new OperationException(
                    $"Operation returned an invalid status code '{response.StatusCode}'",
                    response.StatusCode,
                    body);
                throw ex;
            }

            var conversation = await response.ReadBodyAsJsonAsync<Conversation>().ConfigureAwait(false);

            return conversation;
        }