public HttpResponseMessage SendPostRequest()

in FMLab/ConnectorClientApplication/Helper.cs [41:71]


        public HttpResponseMessage SendPostRequest(Uri uri, string authenticationHeader, string body, ActivityMessage message)
        {
           
            using (HttpClientHandler handler = new HttpClientHandler() { UseCookies = false })
            {
                using (HttpClient webClient = new HttpClient(handler))
                {
                    webClient.DefaultRequestHeaders.Authorization = ParseAuthenticationHeader(authenticationHeader);

                    HttpResponseMessage response;

                    if (body != null)
                    {
                        //convert string into memorystream to be passed in the post request
                        byte[] bytes = Encoding.ASCII.GetBytes(body);
                        MemoryStream memStream = new MemoryStream(bytes);

                        using (StreamContent content = new StreamContent(memStream))
                        {
                            response = webClient.PostAsync(uri, content).Result;
                        }
                    }
                    else
                    {
                        response = webClient.PostAsJsonAsync<ActivityMessage>(uri.ToString(), message).Result;
                    }

                    return response;
                }
            }
        }