#PowerBI – Sending information to Streaming Datasets from a UWP App with C#

Hello!

Today the post is a simple reminder of a piece of code I’ve written from scratch several times, and that’s it, I’m writing this down here! The scenario is simple:

In a PowerBI Instance I have a pair of Streaming Datasets and I want to send information to them from a Windows Store App.

Well, in Hands On Labs that has shared Ozzie (see references), describes the steps to create the Streaming Dataset from scratch and to feed it. However, a bit of code is pending for Windows 10 and C#.

My Streaming DataSet value definition is very simple:

i!

And the source code is even simpler!

private async void ReportVisitorsAsync(string pushUrl, int totalVisitors, int totalVisitorsIdentified, string centerName)
{
var visitorsMeasurement = new
{
TotalVisitors = totalVisitors,
TotalRecognizedVisitors = totalVisitorsIdentified,
timeStamp = DateTime.Now,
CenterName = centerName
};
var jsonString = JsonConvert.SerializeObject(visitorsMeasurement);
var request = WebRequest.Create(pushUrl);
request.Method = "POST";
request.ContentType = "application/json";
using (var requestWriter = new StreamWriter(await request.GetRequestStreamAsync()))
{
requestWriter.Write(jsonString);
requestWriter.Flush();
}
await request.GetResponseAsync();
}

Happy Coding!

Greetings @ Toronto

El Bruno

References

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.