コード例 #1
0
        private HttpRequestMessage BuildRequest(Uri uri, WitRequest witRequest)
        {
            if (this.model.AuthToken == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "Authorization Token");
            }

            var request = new HttpRequestMessage()
            {
                RequestUri = uri,
                Method     = HttpMethod.Post,
            };

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", this.model.AuthToken);
            request.Content = new StringContent(witRequest.Context, Encoding.UTF8, "application/json");

            return(request);
        }
コード例 #2
0
        public HttpRequestMessage BuildRequest(WitRequest witRequest)
        {
            Uri uri = witRequest.BuildUri(this.model);

            return(this.BuildRequest(uri, witRequest));
        }