コード例 #1
0
        public async Task SendTelemetryAsync()
        {
            var url = Helper.BuildUrl(this.@namespace, this.eventHub, this.Publisher);

            var reading = new Reading();
            var serializedReading = JsonConvert.SerializeObject(reading);

            var content = new StringContent(serializedReading);

            var client = new HttpClient();
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("SharedAccessSignature", this.sharedAccessToken);
            var response = await client.PostAsync(url, content);
            Console.WriteLine("{0} {1}", response.StatusCode, response.ReasonPhrase);
        }